# `Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.`

**Where it appears:** Browser

**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 of `onClick={() => setCount(count + 1)}` on a button.
- Calling a `setState` function directly in the component body instead of inside an event handler.

## Message for your agent

```text
React stopped with `Too many re-renders`. Find which state update runs during render instead of inside an event handler and fix it.
```

**Prevention:** Trigger state changes from user actions (clicks and form submissions), not while rendering.

---
Source: [Agentic Makers](https://agenticmakers.app/en/help/errors/too-many-re-renders-infinite-loop) · License: CC BY 4.0
