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) <noreply@anthropic.com>
This commit is contained in:
Marc-André BombeckandClaude Opus 4.7 committed 2026-05-10 14:25:50 +02:00
1 parent 1258b24864
commit 5a8ad3d895
1 file changed
-3
-3
View File
@@ -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);