<StrictMode> is a development-only wrapper that stress-tests components for bugs that concurrent React would expose. It renders nothing visible and has no effect in production builds. Inside it, React: double-invokes render logic (component bodies, state initializers, updaters, reducers, useMemo callbacks) to catch impure rendering; runs an extra setup → cleanup cycle for every effect on mount to catch missing cleanups; in React 19 also runs ref callbacks an extra time on mount; and warns about deprecated APIs (legacy lifecycles, string refs, findDOMNode).
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
createRoot(document.getElementById('root')).render(
<StrictMode>
<App />
</StrictMode>
);
You can wrap only part of the tree to adopt it incrementally. Most frameworks enable it by default.
1. Double rendering: impure render logic
function Cart({ items }) {
items.push({ id: 'promo' }); // mutation during render
return <List items={items} />;
}
Rendering twice makes the promo appear twice, which exposes the mutation. Rendering must be pure because concurrent React may render a component several times before committing, or throw a render away.
React 17 silenced console.log during the second render, which confused people. React 18 stopped hiding it, and React DevTools can show those logs dimmed instead. In React 19, useMemo and useCallback reuse their result from the first render during the second.
2. Effect double-run: missing cleanup
useEffect(() => {
const socket = connect(roomId);
return () => socket.disconnect(); // without this, Strict Mode leaves two connections open
}, [roomId]);
React mounts, simulates an unmount (runs cleanup), then mounts again. If the user-visible behaviour differs from a single mount, your cleanup is wrong. This also prepares for features that preserve state while unmounting UI, such as <Activity> (stable in React 19.2), which can hide and reshow trees.
3. Ref callbacks (React 19): callback refs are attached, cleaned up and re-attached, to validate ref cleanup functions.
4. Deprecated API warnings: UNSAFE_componentWillMount and similar, legacy string refs, legacy context, findDOMNode. Several of these were removed outright in React 19.
Spotted a mistake or a rights concern? Report an issue