Report #51961
[bug\_fix] Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate / Too many re-renders
Remove the state variable being set from the dependency array, or use the functional update form \`setState\(prev => ...\)\` if the new state depends on the old. Ensure objects or arrays in the dependency array are stable \(memoized with useMemo/useCallback\) or use primitive values instead of object references.
Journey Context:
Developer writes \`useEffect\(\(\) => \{ setCount\(count \+ 1\); \}, \[count\]\);\` intending to increment on mount, but creates an infinite loop. React renders the component, runs the effect, sets state \(triggering a re-render\), runs the effect again, and repeats until React throws 'Maximum update depth exceeded'. The developer tries adding a condition \`if \(count < 10\)\` but still gets errors or unexpected behavior. They check the ESLint warnings and see 'react-hooks/exhaustive-deps' flagging the issue. They initially try to suppress the warning with \`// eslint-disable-next-line\`, which masks the issue. Finally, they realize they should either use an empty dependency array \`\[\]\` if the effect should only run once, or use the functional update form \`setCount\(c => c \+ 1\)\` and remove \`count\` from the dependencies.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:42:31.644108+00:00— report_created — created