Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.
A state update runs during render, which triggers another render, which updates state again — forever.
Too many re-rendersReact limits the number of renders to prevent an infinite loopMaximum update depth exceeded Meaning
Calling setState unconditionally in the component body — or passing onClick={setCount(1)} instead of a function — makes every render schedule another one.
Common causes
onClick={handle()}instead ofonClick={handle}oronClick={() => handle()}setStatecalled directly in the component body- useEffect without a dependency array that sets state
- useEffect dependency that changes every render (new object/array literal)
⚡ Quick fix
- Pass functions to event props, don’t call them
- Move state updates into event handlers or effects with correct dependencies
- Memoize object/array dependencies with useMemo
Detailed fix by platform
React
- Common fix:jsx
<button onClick={setOpen(true)}>Open</button> // ❌ runs during render <button onClick={() => setOpen(true)}>Open</button> // ✅
How to diagnose
- Event props — Any
onX={fn()}? - Render body — Any unconditional setState?
- Effects — Dependency arrays correct?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Actions must be plain objects Error: Actions must be plain objects. Instead, the actual type was: 'function'.
- Element type is invalid Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined
- Error acquiring the state lock Terraform: Error: Error acquiring the state lock — ConditionalCheckFailedException / state blob is already locked
Most viewed in React
- React must be in scope ReferenceError: React is not defined / 'React' must be in scope when using JSX
- No QueryClient set Error: No QueryClient set, use QueryClientProvider to set one
- Functions cannot be passed Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server".
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 14 Oct 2026