React Reference ยท react-dom Client APIs
ReactDOM.render (removed)
ReactDOM.render, hydrate and unmountComponentAtNode were removed in React 19. See the old and new code side by side and how to migrate to createRoot.
Before React 18, you started an app with ReactDOM.render(<App />, container). That function, together with ReactDOM.hydrate and ReactDOM.unmountComponentAtNode, belonged to the "legacy root" API. React 18 introduced createRoot and hydrateRoot; the old functions kept working with a warning. React 19 removes them: they no longer exist on the react-dom export, so calling them throws TypeError: ... is not a function.
Migration is mostly mechanical. The result is the same app, running on the modern concurrent renderer with automatic batching and the new error-handling options.
// Before (React 17 and earlier) import { render } from 'react-dom'; render(<App />, document.getElementById('root')); // After (React 18 and 19) import { createRoot } from 'react-dom/client'; createRoot(document.getElementById('root')).render(<App />);
Try it
Migration table
| Removed call | Replacement |
|---|---|
ReactDOM.render(element, container) |
const root = createRoot(container); root.render(element) |
ReactDOM.render(element, container, callback) |
Put the work in a useEffect or a ref callback inside the tree; root.render has no callback |
ReactDOM.hydrate(element, container) |
hydrateRoot(container, element) |
ReactDOM.unmountComponentAtNode(container) |
Keep the root from createRoot and call root.unmount() |
ReactDOM.findDOMNode(instance) |
A ref, see findDOMNode (removed) |
import { render } from 'react-dom' |
Import from react-dom/client |
Calling render repeatedly to update |
Keep one root and call root.render(newElement) |
Usage notes
- Hold on to the root.
unmountComponentAtNodefound the root from the container; withcreateRoot, you must keep the variable thatcreateRootreturned if you want to update or unmount later. - Import path:
createRootandhydrateRootare inreact-dom/client, whilecreatePortalandflushSyncstay inreact-dom. - Behavior changes you may notice after migrating: updates are batched everywhere (timeouts, promises, native events), StrictMode double-invokes effects in development, and a tree that throws without an error boundary is unmounted.
- Tests written against the legacy API usually need
IS_REACT_ACT_ENVIRONMENT = trueandact(), or a library such as React Testing Library at a version that supports React 19. - The default
render(<App />, container)cleared the container just likecreateRoot, so you do not need to reset it by hand. - Libraries that call
ReactDOM.renderinternally (older widget libraries, some docs tools) will break on React 19 until updated. - If you cannot upgrade a dependency yet, stay on React 18 for now; its legacy root still works with a console warning.