ReactDOM.render is no longer supported in React 18
React JavaScript Library
Severity: MinorWhat it means
React 18: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17.
The same for server rendering: ReactDOM.hydrate is no longer supported in React 18. Use hydrateRoot instead.
React 19 removed ReactDOM.render and ReactDOM.hydrate, so calling them fails instead of warning.
Affected Models
- React 18 and 19
How to Fix It
-
Change the entry file, often index.js or main.jsx. Import from react-dom/client: import { createRoot } from 'react-dom/client'.
-
Replace ReactDOM.render(<App />, container) with two lines: const root = createRoot(container); then root.render(<App />).
-
Server-rendered page? Replace ReactDOM.hydrate(<App />, container) with hydrateRoot(container, <App />), also from react-dom/client.
-
React's upgrade guide offers a codemod that does it for you: npx codemod@latest react/19/replace-reactdom-render.