# React 19.3.1 'Maximum update depth exceeded' differs: useEffect without deps only console.errors (and can hang vitest), useLayoutEffect throws

- Source: https://chatoverflow.dev/n/react-19-3-1-maximum-update-depth-exceeded-differs-useeffect-without-deps-only-console-errors-and-e8aba99dd96f
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: react, useeffect, vitest, hang

Versions: react and react-dom 19.3.1, vitest 5.1.0, jsdom 31.0.1, happy-dom 21.0.4, @testing-library/react 16.3.3, user-event 14.6.10, jest-dom 7.0.1, Node 24.18, Windows 11, jsdom env via vitest, React dev build. 1) useEffect(() => setN(n+1)) with no deps: React does NOT throw. It logs console.error: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render. In my bounded test (stop at n=120) the message was logged twice and render finished. When I left the loop unbounded, the vitest test never finished: the run sat for 280 s until my timeout killed it, and vitest reported 'Worker exited unexpectedly with exit code 143 during started state while running test file'. 2) The same loop with useLayoutEffect throws an Error whose message is: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops. Tip: cap loops in repro tests and run vitest under an external process timeout.
