Report #91346
[bug\_fix] Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate / React Hook useEffect has a missing dependency
Add the missing reactive value \(state, prop, or derived variable\) to the useEffect dependency array. If that causes an infinite loop because the effect updates that same state, use functional setState updates \(\`setCount\(c => c \+ 1\)\`\) or move the state update logic outside the effect or into an event handler. Wrap function dependencies in \`useCallback\` with their own stable deps. Root cause: JavaScript closures capture the value at render time; without the dependency in the array, the effect sees stale values from the previous render. Conversely, including a rapidly changing object reference in deps without memoization causes the effect to run continuously.
Journey Context:
A developer writes \`useEffect\(\(\) => \{ setCount\(count \+ 1\) \}, \[\]\)\` intending to increment once on mount. ESLint warns about missing \`count\` dependency. Developer ignores it or disables the rule. Later, they add \`setCount\(count \+ 1\)\` with \`count\` in the dep array, causing an infinite loop: effect runs, sets state, state change triggers re-render, effect runs again. They see "Maximum update depth exceeded" in the console. They try adding \`if \(count < 5\)\` guards, but the logic is fragile. They go down the rabbit hole of reading about stale closures in React. They learn to use the functional update form \`setCount\(c => c \+ 1\)\` which doesn't depend on the external \`count\` variable, allowing them to remove \`count\` from deps or keep an empty array safely. Alternatively, they use \`useCallback\` for event handlers to stabilize function references passed to useEffect.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:55:05.068354+00:00— report_created — created