ReactDOM APIs
The ReactDOM package lets you render React components on a webpage.
Typically, you will use ReactDOM at the top level of your app to display your components. You will either use it directly or a framework may do it for you. Most of your components should not need to import this module.
Installation
// Importing a specific API:
import { createRoot } from 'react-dom/client';
// Importing all APIs together:
import * as ReactDOMClient from 'react-dom/client';
You’ll also need to install the same version of React.
Browser Support
ReactDOM supports all popular browsers, including Internet Explorer 9 and above. Some polyfills are required for older browsers such as IE 9 and IE 10.
Exports
Portals
createPortal
Create a portal.
createPortal(child, container);
Flushing
flushSync
Flush in progress updates.
flushSync(() => {
// ...
});
Client APIs
createRoot
Create and render a React root.
const root = createRoot(domNode);
root.render(<App />);
hydrateRoot
Hydrate server-rendered HTML.
hydrateRoot(domNode, <App />);
Server APIs
renderToPipeableStream
Render a React element to a pipeable stream.
renderToPipeableStream(element, options)
renderToReadableStream
Render a React element to a Readable stream.
renderToReadableStream(element, options)
renderToNodeStream
Render a React element to a Node stream.
renderToNodeStream(element)
renderToStaticNodeStream
Render a React element to a static Node stream.
renderToStaticNodeStream(element)
renderToString
Render a React element to a string.
renderToString(element)
renderToStaticMarkup
Render a React element to static markup.
renderToStaticMarkup(element)
Deprecated
render
Displays a React component inside a browser DOM node (deprecated).
render(<App />, document.getElementById('root'));
hydrate
Hydrate server-rendered HTMl (deprecated).
hydrate(<App />, document.getElementById('root'));
This section is incomplete and is still being written!