Skip to content
Tutorials Center
My learning

Topics

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.

JSX
// 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

What is left in react-dom
The migrated code

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. unmountComponentAtNode found the root from the container; with createRoot, you must keep the variable that createRoot returned if you want to update or unmount later.
  • Import path: createRoot and hydrateRoot are in react-dom/client, while createPortal and flushSync stay in react-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 = true and act(), or a library such as React Testing Library at a version that supports React 19.
  • The default render(<App />, container) cleared the container just like createRoot, so you do not need to reset it by hand.
  • Libraries that call ReactDOM.render internally (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.