Browser
Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.
- What it means
- A component keeps updating its own state every time it draws, causing an endless loop that React stops.
- Likely causes
- Writing
onClick={setCount(count + 1)}instead ofonClick={() => setCount(count + 1)}on a button. - Calling a
setStatefunction directly in the component body instead of inside an event handler.
- Writing
- Prevention
- Trigger state changes from user actions (clicks and form submissions), not while rendering.
Copy for your agent
React stopped with `Too many re-renders`. Find which state update runs during render instead of inside an event handler and fix it.
Was this page helpful?