← All errors · Bolt

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.

Related errors

Get new fixes weekly

No spam. Unsubscribe anytime. Privacy