Report #10618
[bug\_fix] Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate
Use functional state updates to avoid stale closures, or memoize the dependency with useMemo, or switch to a primitive dependency value instead of object/array reference
Journey Context:
Developer writes: useEffect\(\(\) => \{ setData\(processData\(rawData\)\) \}, \[rawData\]\). rawData is an object created inline in the parent: rawData=\{\{ id: 1 \}\}. Every render creates a new object reference. The effect runs, calls setData, triggers a re-render, parent re-renders creating new rawData object, effect runs again. Developer sees 'Maximum update depth' error. They try adding empty deps \[\], but then data never updates. They try using JSON.stringify\(rawData\) as a dep, which works but is inefficient. Finally, they realize they should either lift the data processing out of useEffect, use useMemo for the processed data instead of useEffect\+setState, or ensure the dependency is a stable primitive like rawData.id.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T11:14:07.677240+00:00— report_created — created