Report #24085
[bug\_fix] Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate.
Use primitive values in the useEffect dependency array instead of objects/arrays, or memoize the object with useMemo before passing it to the dependency array, or use functional state updates to avoid needing the state variable in dependencies.
Journey Context:
Developer writes a useEffect that synchronizes state with props, placing an object defined inline in the dependency array: useEffect\(\(\) => \{ setData\(props.config\) \}, \[props.config\]\). On every render, props.config is a new object reference even if contents are identical. The effect runs, calls setState, triggers a re-render, creates a new object reference, causing the effect to run again, creating an infinite loop. The browser hangs or shows the maximum depth error. Debugging with React DevTools shows rapid re-renders. The developer realizes object reference equality is changing between renders. The fix involves either removing the object from dependencies \(if safe\), wrapping it in useMemo to maintain reference stability, or using the functional update form setData\(prev => ...\) to avoid needing the current data in the dependency array altogether.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T18:50:18.910603+00:00— report_created — created