Common Next.js errorsMaximum update depth exceeded
Error: Maximum update depth exceeded means a component keeps setting state, which re-renders it, which sets state again, until React stops the loop.
The usual causes
// 1. Calling a setter during render
<button onClick={setOpen(true)}> // runs on every render
<button onClick={() => setOpen(true)}> // runs on click
// 2. An effect that sets the state it depends on
useEffect(() => setItems([...items, x]), [items])
// 3. A new object or array in the dependency list every render
useEffect(() => load(filters), [{ ...filters }])
How to fix it
Pass a function to event handlers instead of calling the setter. In effects, depend on stable values (ids, strings, numbers), use the updater form setItems((prev) => [...prev, x]) so the effect doesn't need items, and compute derived values during render instead of storing them in state.