Report #96595
[bug\_fix] React Hook useEffect has a missing dependency: 'X'
Add the missing variable to the dependency array, or move the variable inside useEffect if it shouldn't trigger re-runs. If it's a function, use useCallback or move it inside. Root cause: ESLint rule detects that values used inside useEffect but not in deps array will be stale \(closure captures old value\), causing bugs where effect doesn't re-run when data changes.
Journey Context:
Developer builds a dashboard fetching user data. Writes: \`useEffect\(\(\) => \{ fetchUser\(userId\); \}, \[\]\);\`. ESLint warns about missing dependency \`userId\`. Developer ignores it, thinking 'I only want it to run once on mount.' Later, when navigating from \`/user/1\` to \`/user/2\`, the component doesn't re-fetch data because useEffect doesn't re-run. Developer spends hours debugging why stale data shows. Checks React DevTools, sees props changed but effect not running. Remembers the ESLint warning. Adds \`userId\` to dependency array. Component now correctly re-fetches when \`userId\` changes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:43:11.851737+00:00— report_created — created