From 5a8ad3d89501b430dbcef95793bb52f38cb477ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 10 May 2026 14:25:50 +0200 Subject: [PATCH] fix(charts): drop the redundant resize sync from useViewportWidth The useState lazy initialiser already runs on the client during hydration and reads the live `window.innerWidth`, so the post-mount handler() call was a no-op that triggered a setState inside useEffect. The eslint react-hooks/set-state-in-effect rule flags this pattern; removing it lets the resize + orientationchange listeners alone drive updates without a hydration-time double set. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/hooks/use-viewport-width.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/hooks/use-viewport-width.ts b/src/hooks/use-viewport-width.ts index 7afbf19ae..d6a357947 100644 --- a/src/hooks/use-viewport-width.ts +++ b/src/hooks/use-viewport-width.ts @@ -22,9 +22,6 @@ export function useViewportWidth(): number { const handler = () => setWidth(getViewportWidth()); window.addEventListener("resize", handler); window.addEventListener("orientationchange", handler); - // Sync once after mount in case the SSR default differs from the - // first browser-side measurement. - handler(); return () => { window.removeEventListener("resize", handler); window.removeEventListener("orientationchange", handler);