Report #69674
[bug\_fix] Maximum update depth exceeded / React Hook useEffect has a missing dependency
Root cause: The dependency array in \`useEffect\` is missing a variable used inside, causing a stale closure, OR an object/array dependency is recreated on every render \(new reference\), triggering the effect infinitely when that effect updates state. Fix: Add all primitive dependencies to the array. For objects/arrays, stabilize them with \`useMemo\` or use functional state updates \(\`setState\(prev => ...\)\`\) to remove the state variable from dependencies.
Journey Context:
Developer writes \`useEffect\(\(\) => \{ fetchData\(query\).then\(setData\) \}, \[\]\)\`. The ESLint rule \`react-hooks/exhaustive-deps\` warns that \`query\` is missing. The developer adds \`query\` to the array, but \`query\` is an object literal \`\{\}\` defined inside the component. The effect runs, calls \`setData\`, triggers a re-render, creates a new \`query\` object reference, and the effect runs again—creating an infinite loop. The developer sees the "Maximum update depth" error. Using React DevTools Profiler, they see rapid commits. They realize the object identity issue and refactor to depend on \`query.id\` \(a primitive\) or wrap the object in \`useMemo\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T23:26:00.465694+00:00— report_created — created