React Diagnostic

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

React throws this error when a component schedules a state update during its render phase or inside an uncontrolled useEffect loop, exceeding the maximum recursion threshold (50 renders).

Maximum update depth exceeded

Quick Fix Checklist

  1. Check all onClick or event handlers: ensure you are passing a function definition, not calling it immediately
  2. Move state updates inside useEffect or callback event handlers rather than the main component body
  3. Verify useEffect dependency arrays: use primitive values (strings, numbers, booleans) instead of new object/array literals
  4. Use functional state updates (setCount(prev => prev + 1)) to remove state variables from effect dependencies