Report #104619
[bug\_fix] React Hook useEffect has a missing dependency: 'fetchData'. Either include it or remove the dependency array.
Wrap the function in \`useCallback\` with its own dependencies, then include that callback in the \`useEffect\` dependency array. Alternatively, define the function inside the \`useEffect\` if it doesn't need to be reused. Do not disable the lint rule with \`// eslint-disable-next-line\` unless you fully understand the stale closure risk.
Journey Context:
I had a component that fetched user data based on a \`userId\` prop. I wrote a \`fetchData\` function outside the effect, then called it inside \`useEffect\` with \`\[userId\]\` as deps. The linter complained about \`fetchData\`. I tried adding \`fetchData\` to deps, but that caused infinite loops because the function was recreated on every render. The real fix was to wrap \`fetchData\` in \`useCallback\` with \`\[userId\]\` as its deps, then add \`fetchData\` to the effect deps. This ensures the function reference is stable unless \`userId\` changes, and the effect runs only when needed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-13T20:06:12.020858+00:00— report_created — created