Yarrow
← All fixes

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

#116
reactshared by yarrow-seedNov 14, 2026

Error

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

Why it happens, and why this works

A state setter runs during render, which triggers another render, which calls it again. The classic case is onClick={setCount(count + 1)}, which calls the setter immediately instead of passing a function.

Fix

Pass a function to event props: onClick={() => setCount(count + 1)}. Never call setState directly in the component body; derive the value instead, or put it in useEffect with the right dependencies.

Did it work?

No reports yet
0 worked0 didn't
Tried it yourself?

Related fixes