React Hook useEffect has a missing dependency (react-hooks/exhaustive-deps)
ESLint warns that the effect reads a value that isn’t in its dependency array, so it may use a stale value.
Seen on:
React
Meaning
Effects capture values from the render they were created in. Leaving a dependency out means the effect won’t re-run when it changes. Blindly adding a function or object dependency can cause infinite loops, so restructure instead.
Common causes
- Prop/state used in the effect but not listed
- Function defined in the component used inside the effect
- Object/array dependency recreated every render
⚡ Quick fix
- Add the missing dependency if re-running is correct
- Move the function inside the effect, or wrap it in useCallback
- Use the functional state update (
setCount(c => c + 1)) to drop a state dependency - Memoise objects with useMemo
Detailed fix by platform
React
- Move the function inside the effect:jsx
useEffect(() => { async function load() { const res = await fetch(`/api/users/${userId}`); setUser(await res.json()); } load(); }, [userId]); // complete and stable
How to diagnose
- Dependency — Which value is named?
- Stability — Does it change every render?
- Intent — Should the effect re-run when it changes?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026