← All errors · BoltReact & Next.js rendering errors

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

Exact error

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

What it means

A state update runs during render, which triggers another render, endlessly.

Likely causes

How to fix it

  1. Pass a function to event handlers:

    // wrong
    <button onClick={setOpen(true)}>Open</button>
    // right
    <button onClick={() => setOpen(true)}>Open</button>
  2. Move derived/initial updates into useEffect with correct dependencies, or compute values without state.

Prevent this next time

Guide: catch outages before your users do.

FAQ

What does "Too many re-renders. React limits the number of renders to prevent an infinite loop" mean?

A state update runs during render, which triggers another render, endlessly.

What usually causes it?

Calling a setter directly in the component body. onClick={setCount(1)} (calls immediately) instead of passing a function.

How do I fix it?

1. Pass a function to event handlers: 2. Move derived/initial updates into useEffect with correct dependencies, or compute values without state.

Related errors

Get new fixes weekly

No spam. Unsubscribe anytime. Privacy