Skip to content
SprecherEast
Issue 193

tech-debt: Fix the 9 places that break the React Compiler lint rules, then turn them on

Back to our plan
Open
frontendtech-debtpriority: medium

Type

tech-debt

Summary

Next 16's ESLint config adds three React rules: react-hooks/set-state-in-effect, react-hooks/refs and react-hooks/purity. They come from eslint-plugin-react-hooks 7, the React Compiler rules. Nine places in today's code break them. The Next 16 upgrade (#120) turns the three rules off so it stays a pure upgrade. This issue fixes those nine places and turns the rules back on as errors.

Problem

The nine places:

FileLineRule
src/Header/Component.client.tsx36, 41set-state-in-effect
src/blocks/Form/Component.tsx174refs
src/components/Card/index.tsx49, 98refs
src/components/VersionCheck/index.tsx14purity (Date.now during render)
src/components/VersionCheck/index.tsx77set-state-in-effect
src/providers/Theme/ThemeSelector/index.tsx33set-state-in-effect
src/providers/Theme/index.tsx38set-state-in-effect

Setting state directly in an effect causes an extra render. Reading refs or calling Date.now during render makes the output unpredictable. See https://react.dev/learn/you-might-not-need-an-effect, opens in a new tab.

Proposed fix

  • Fix each place the way the rule suggests:
    • derive the value during render, or use a lazy useState initializer;
    • read refs in effects or event handlers only;
    • move Date.now into an effect or an event.
  • Turn the three rules back on in eslint.config.mjs (remove the off lines added by #120).
  • Run a visual check of the header, theme selector, cards and forms. These components render on every page.

Acceptance criteria

  • Not done: npx eslint . reports none of the three rules, with them set to error.
  • Not done: The header, theme switch, cards, form and version check behave as before, checked at 375 and 1280 px in light and dark.

Depends on

#120 (Next 16).

Area

frontend

Priority

priority: medium


Generated by Claude Code, opens in a new tab

See it on GitHub, opens in a new tab