react-doctor/exhaustive-deps
Match the deps array to what the hook callback actually captures, or stabilize/move recreated values instead of blindly adding them.
- Category: Bugs
- Severity: warn
- Source:
oxlint-plugin-react-doctor - Framework: global
- Enabled when: always
- Tags: test-noise
- Default: Enabled
- Documentation: https://oxc.rs/docs/guide/usage/linter/rules/react/exhaustive-deps
Validate the diagnostic
Confirm the reported code matches this rule before you edit it.
Fires on useEffect, useLayoutEffect, useInsertionEffect, useCallback, useMemo, useImperativeHandle, and configured additional hooks when the dependency array omits a reactive capture or contains an invalid dependency. Effects may intentionally omit the array, and unused reactive effect dependencies are allowed. useMemo and useCallback require dependency arrays and report unused dependencies. All supported hooks report duplicates, spreads, literals, computed members, ref.current, useEffectEvent, inline-recreated values, and outer-variable assignments. Stable setters, dispatch, startTransition, ref bindings, effect-event handlers, module imports, and primitive local constants do not need dependencies.
How to fix
Follow the rule guidance while preserving unrelated behavior.
Copyable fix prompt
Copy this self-contained prompt into your coding agent after you confirm the diagnostic.
useMemo and useCallback; an effect may intentionally run after every render without one. Move recreated values into the callback or stabilize them before adding them. Use functional state updates to remove captured state, depend on the ref instead of ref.current, and avoid spreads or computed expressions. Add a narrow suppression with a written reason only when exclusion is intentional. See https://oxc.rs/docs/guide/usage/linter/rules/react/exhaustive-depsRelated rules
More Bugs rules from the rules reference:
react-doctor/expo-no-non-inlined-env: Use static dotted access: process.env.EXPO_PUBLIC_NAME (computed/destructured reads aren't inlined and are undefined at runtime)react-doctor/form-control-requires-name: Form control is omitted from named submission datareact-doctor/hook-import-rename-loses-use-prefix: Hook import alias disables hook lint checksreact-doctor/hooks-no-nan-in-deps: Remove the literal NaN from the dependency array, or normalise it (Number.isNaN(x) ? 0 : x) before passing it in.react-doctor/html-label-has-single-control: Label wraps multiple native controls