mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
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:
1 parent
1258b24864
commit
5a8ad3d895
1 file changed
-3
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user