Report #102879
[bug\_fix] React Hook useEffect has a missing dependency: 'value'. Either include it or remove the dependency array.
Add all reactive values used inside the effect to the dependency array, or refactor to use functional state update \(e.g., \`setCount\(c => c \+ 1\)\`\) if the dependency is only used to compute the next state.
Journey Context:
I had a component that fetched data when a prop \`userId\` changed. I wrote \`useEffect\(\(\) => \{ fetchUser\(userId\); \}, \[\]\)\`. ESLint warned about missing \`userId\`. I ignored it, thinking the effect should only run once. Later, when \`userId\` changed, the effect didn't re-run, causing stale data. After debugging, I read the React docs on useEffect and learned that omitting a dependency that is used inside the effect leads to stale closures. The effect captured the initial \`userId\` and never updated. The correct fix was to add \`userId\` to the dependency array: \`useEffect\(\(\) => \{ fetchUser\(userId\); \}, \[userId\]\)\`. If I only wanted the effect to run when \`userId\` changes, that's exactly what the dependency array does. Including all deps ensures the effect is re-executed when those values change, maintaining correctness.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T15:49:20.839279+00:00— report_created — created