Report #72203
[bug\_fix] React Hook useEffect has a missing dependency: 'someVar'. Either include it or remove the dependency array \(ESLint react-hooks/exhaustive-deps\)
Include all reactive values \(props, state, variables derived from them\) used inside useEffect in the dependency array. If including a value causes infinite loops because it changes every render, use a ref for mutable values, or use functional state updates, or move the logic inside the effect.
Journey Context:
Developer writes useEffect to fetch user data when userId changes: useEffect\(\(\) => \{ fetchData\(userId, page\); \}, \[userId\]\). The ESLint plugin warns about missing 'page' dependency. Developer ignores it. Later, when page state changes, the effect doesn't re-run, causing stale data to display. Developer adds page to deps, but now gets infinite loop because fetchData updates page state. Realizes the dependency array must include all values used in effect, but needs to restructure: either use functional update setPage\(p => p \+ 1\) to avoid dependency on page, or move fetch logic into the effect with empty deps and use a ref for mutable values. Learns that exhaustive-deps rule prevents stale closures where effect captures values from previous render cycle.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:46:39.534084+00:00— report_created — created