Skip to content

react-hooks/set-state-in-effect fires on 12 effects, downgraded to a warning during the Next 16 migration #95

Open

Description

@blitzcrieg1

eslint-config-next@16 adds react-hooks/set-state-in-effect, which errors on 12 existing effects across five components.

It was downgraded to a warning in eslint.config.mjs during the Next 16 migration so the upgrade stayed reviewable, not because the rule is wrong.

Where they are

Count File
5 components/flight-recorder-panel.tsx
3 components/detections-panel.tsx
2 components/mission-control.tsx
1 components/dogfood-gate.tsx
1 components/theme-toggle.tsx

Why it is not a one-line fix

The rule is right that a synchronous setState inside an effect causes a second render. But the shape it flags most often here is the hydration guard next-themes documents:

const [mounted, setMounted] = React.useState(false);
React.useEffect(() => setMounted(true), []);
if (!mounted) return <placeholder />;

That exists specifically to avoid a server/client mismatch and has no direct replacement. The others need reading individually: some are probably genuine improvements, some are the same guard in a different shape.

Twelve behaviour-adjacent refactors in a live dashboard is not something to bundle into a framework migration, which is why they are a warning and an issue rather than a rushed commit.

Done when

Each site is either fixed or carries a per-line disable with a reason, the block in eslint.config.mjs is deleted, and the rule errors again.

Start with theme-toggle.tsx: one effect, clearest case, and it establishes the pattern for the rest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions