Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: added fix for useDimensions returing 0,0 on mount (#10154)

Abhi kumar659fa361efa7
diff --git a/frontend/src/hooks/useDimensions.ts b/frontend/src/hooks/useDimensions.ts
index 8679657a4e..0f6bad6dee 100644
--- a/frontend/src/hooks/useDimensions.ts
+++ b/frontend/src/hooks/useDimensions.ts
@@ -16,13 +16,19 @@ export function useResizeObserver<T extends HTMLElement>(
});
useEffect(() => {
- const handleResize = debounce((entries: ResizeObserverEntry[]) => {
- const entry = entries[0];
- if (entry) {
- const { width, height } = entry.contentRect;
- setSize({ width, height });
- }
- }, debounceTime);
+ const handleResize = debounce(
+ (entries: ResizeObserverEntry[]) => {
+ const entry = entries[0];
+ if (entry) {
+ const { width, height } = entry.contentRect;
+ setSize({ width, height });
+ }
+ },
+ debounceTime,
+ {
+ leading: true,
+ },
+ );
const ro = new ResizeObserver(handleResize);
const referenceNode = ref.current;