react
rendering
ai_generated
true
Error: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect
ID: react/maximum-update-depth-exceeded
95%Fix Rate
96%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 18 | active | — | — | — |
Root Cause
useEffect triggers a state update that re-triggers the effect in an infinite loop.
genericWorkarounds
-
95% success Add correct dependencies to the useEffect dependency array
Ensure deps don't change on every render — avoid object/array literals in deps
Sources: https://react.dev/reference/react/useEffect#removing-unnecessary-dependencies
-
92% success Use useMemo/useCallback for deps that are computed values or functions
Memoization prevents the dependency from changing on every render
Dead Ends
Common approaches that don't work:
-
Adding a counter to limit the number of updates
70% fail
Adds complexity without fixing the root cause; effect still fires unnecessarily
-
Removing the useEffect entirely
60% fail
May break the feature that needs the side effect
Error Chain
Frequently confused with: