Too many re-renders React infinite loop

Too many re-renders

Quick Answer

A state update triggers another render, creating an infinite loop.

Why This Happens

In React, a state update triggers another render, creating an infinite loop. This is one of the most common React errors developers encounter. Understanding the root cause helps you fix it quickly and prevent it from recurring.

The Problem

function App() {
  const [c, setC] = useState(0);
  setC(c + 1); // In render!
}

The Fix

function App() {
  const [c, setC] = useState(0);
  return <button onClick={() => setC(c+1)}>{c}</button>;
}

Step-by-Step Fix

  1. 1

    Identify the error

    Look at the error message: Too many re-renders. This tells you exactly what went wrong.

  2. 2

    Find the cause

    Check the stack trace to find which line of your React code triggered this error.

  3. 3

    Apply the fix

    Use the corrected code pattern shown above. Test to confirm the error is resolved.

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free