Fix React hooks ESLint errors without disabling rules

Refactored components to avoid synchronous setState calls in effects
by using proper React patterns:

- TableOfContents: Use requestAnimationFrame to defer setState calls
  and useLayoutEffect for DOM measurements
- CustomTheme: Use lazy state initialization for isClient and defer
  theme loading with requestAnimationFrame
- PlaygroundContext: Use lazy initialization for localStorage hydration

These changes maintain functionality while satisfying the strict
react-hooks/set-state-in-effect ESLint rule.

Signed-off-by: Charles de Dreuille <charles.dedreuille@gmail.com>
This commit is contained in:
Charles de Dreuille
2026-01-29 15:00:58 +00:00
parent 9db03083a0
commit ad435e4344
4 changed files with 59 additions and 61 deletions
-2
View File
@@ -9,8 +9,6 @@ const eslintConfig = defineConfig([
'notice/notice': 'off',
'react/forbid-elements': 'off',
'jsx-a11y/alt-text': 'off',
'@next/next/no-css-tags': 'off',
'react-hooks/set-state-in-effect': 'warn',
},
},
]);