react-doctor/rendering-hydration-no-flicker
Use `useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)` or add `suppressHydrationWarning` to the element
- Category: Performance
- Severity: warn
- Source:
oxlint-plugin-react-doctor - Framework: global
- Enabled when: always
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Confirm a useEffect or useLayoutEffect with an empty [] deps array whose body is a single statement that calls a setter matching /^set[A-Z]/. This flips state once on mount, causing a visible server-vs-client flash. False positive: the setState is part of an unavoidable hydration workaround.
Fix prompt
Use this once validation confirms the diagnostic is real.
Replace with useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) so the server renders the placeholder and the client subscribes to the live value in a single commit — no post-mount re-render. Alternatively add suppressHydrationWarning to the affected element if a brief mismatch is acceptable. See https://react.dev/reference/react/useSyncExternalStore
Related rules
More Performance rules from the rules reference:
react-doctor/rendering-script-defer-async: Add `defer` for DOM-dependent scripts or `async` for independent ones (analytics). In Next.js, use `<Script strategy="afterInteractive" />` insteadreact-doctor/rendering-svg-precision: Truncate path/points/transform decimals to 1–2 digits — sub-pixel precision adds bytes with no visible differencereact-doctor/rendering-usetransition-loading: Replace with `const [isPending, startTransition] = useTransition()` — avoids a re-render for the loading statereact-doctor/rerender-defer-reads-hook: Read the URL state inside the handler (e.g. `new URL(window.location.href).searchParams`) so the component doesn't subscribe and re-render on every URL changereact-doctor/rerender-derived-state-from-hook: Use a threshold/media-query hook (e.g. `useMediaQuery("(max-width: 767px)")`) — the component re-renders only when the threshold flips, not every pixel