Report #84867
[bug\_fix] Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate.
Review the dependency array of \`useEffect\` \(or \`useLayoutEffect\`\). Remove unstable object/array references created inline in the component body, or use a functional update \`setState\(prev => ...\)\` if the new state depends on the previous state. Root cause: A dependency that changes identity on every render triggers the effect recursively, or a missing dependency causes logic to run unexpectedly.
Journey Context:
Developer has a \`useEffect\` that synchronizes an external prop to local state: \`useEffect\(\(\) => \{ setValue\(prop\) \}, \[prop\]\)\`. However, \`prop\` is an object \`\{ id: 1 \}\` that is recreated by the parent on every render, causing the effect to run every time, which calls setState, triggering a re-render, and since the parent still passes a new object, it loops infinitely. The console shows 'Maximum update depth exceeded'. Developer uses React DevTools Profiler or adds console logs to see why it's re-rendering. They realize the dependency array contains an unstable reference. They either wrap the prop in \`useMemo\` in the parent, or in the child they use \`JSON.stringify\(prop\)\` as the dependency \(hacky but works for simple objects\), or better, they compare the values inside the effect before calling setState, or use a ref to track if it's the first render. The standard fix is ensuring the dependency is stable or using functional updates.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:02:12.254674+00:00— report_created — created