Report #99114
[bug\_fix] React Hook useEffect has a missing dependency: 'someValue'. Either include it or remove the dependency array
Add every value used inside the effect that can change over render to the dependency array. If the linter wants a function or object that is recreated every render, memoize it with useCallback/useMemo, or move the value creation inside the effect. If you deliberately want an effect to run only once, initialize mutable refs or state inside the effect itself rather than lying to the dependency array.
Journey Context:
A developer writes an effect that fetches user data based on a userId prop. They add \[\] as dependencies because they think it should run only on mount. Later, navigating between profiles reuses the component and keeps showing the previous user's data. They add userId to the array, then ESLint complains about a fetch helper function declared in the component body. They try disabling the rule, which hides the warning but the bug returns when the helper closes over a stale theme prop. They eventually move the helper inside the effect, include userId and the stable base URL, and use useCallback only for event handlers passed up to parents. The effect now re-runs exactly when its real inputs change, and stale closures disappear.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-29T04:35:47.923542+00:00— report_created — created