Maximum update depth ⚛️ React

Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate.

A component keeps updating itself in an effect or lifecycle — usually a useEffect that sets state its own dependencies change.

Seen on: React

Meaning

Effects without proper dependencies, or dependencies that are new objects each render, trigger setState → render → effect → setState endlessly.

Common causes

  • useEffect setting state with no dependency array
  • Object/array dependency recreated every render
  • componentDidUpdate calling setState unconditionally

⚡ Quick fix

  1. Add correct dependencies
  2. Memoize objects with useMemo/useCallback
  3. Compare before setting state

Detailed fix by platform

React

  1. useEffect(() => { if (value !== prev) setPrev(value); }, [value, prev]);

How to diagnose

  1. Effect — Which effect sets state?
  2. Deps — Stable dependencies?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.