React error
Minified React error #185: Maximum update depth exceeded
"Minified React error #185" is the production form of "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." React throws it after more than 50 nested updates in a row, and an uncaught one removes the whole UI, so the page goes blank. In a production build of react-dom 19.3.1 it came from setState in a useLayoutEffect with no dependency array, from an inline ref callback that sets state, and from a getSnapshot that returns a new object on every call. A useEffect loop did not raise it. Run the same screen in development to read the full message. Reproduced with react-dom 19.3.1 on 2026-10-31.
What is the full message behind Minified React error #185?
The production build ships the error code and a link instead of the text, and the code list in the React repository maps 185 to the message. The development build throws that same text. In development, the getSnapshot case also logs "The result of getSnapshot should be cached to avoid an infinite loop" first.
Minified React error #185; visit https://react.dev/errors/185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
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.Which code causes error 185 in an AI-built React app?
Each case below threw #185 in a production build of react-dom 19.3.1 and the full message in development. In all three, a render triggers the state update that causes the next render, and React stops after 50 nested updates. A page with no error boundary above the crash then loses its whole UI; the React docs say React removes the UI from the screen.
// 1. setState in a layout effect with no dependency array
useLayoutEffect(() => { setCount(count + 1); });
// 2. an inline ref callback is a new function on every render
<p ref={(el) => setNode({ el })}>x</p>
// 3. getSnapshot returns a new object on every call
useSyncExternalStore(subscribe, () => ({ a: 1 }));Why does my useEffect loop not show error 185 in production?
The limit for passive effects, which is what useEffect uses, sits inside an if (__DEV__) block in ReactFiberWorkLoop.js and only logs a console error. With the update capped at 1000 by a guard, the production build raised no error, and the development build logged "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." React's own check for this loop is not in a production build, so find it in development.
Checklist
How to fix it, then check the fix
- 01Reproduce the screen in development and read the full message in the console:
npm run dev - 02List the code that updates state from a layout effect, a ref callback or an external store:
grep -rnE "useLayoutEffect|useSyncExternalStore|ref=\{\(" src - 03Give an effect a dependency array that lists only the values that should run it again, or remove the effect when the state can be worked out during render. The useEffect docs name an Effect that updates state, and so changes its own dependencies, as the cause of an infinite cycle.
- 04Pass a stable function as the ref, and return the stored value from getSnapshot instead of a new object:
const [node, setNode] = useState(null); <p ref={setNode}>x</p> useSyncExternalStore(subscribe, () => myStore.todos); // the stored value - 05Put an error boundary above the routes, so a crash in one component shows a fallback and the rest of the page stays.
- 06Build the app, open the same screen from the production build, and check that the console has no #185 and the page renders.
Related
Related guides
Sources
Official docs behind this checklist
Browse all launch guides · Read resources · How to make and check your next change
FAQ
FAQ for builders before launch
Is error 185 the same as "Too many re-renders"?
No. Calling setState during render gave Minified React error #301 in a production run, and "Too many re-renders. React limits the number of renders to prevent an infinite loop." in development. The three cases above gave #185.
Why does the error show only a number?
The production build of React ships error codes instead of full text, and the code list in the React repository maps each number to its message. The minified text links to react.dev/errors/185 for the full version.
Does Vite cause error 185?
The limit is inside react-dom, and Vite only bundles it. A loop in your components raises the same error whichever tool built the app.