← React Beginner Questions - Set 2 Q11
React Beginner Questions - Set 2
React builds the tree; react-dom is the package that talks to the browser and puts it on screen. Since React 18 it is also where the root lives.
import { createRoot } from 'react-dom/client';
import App from './App';
const container = document.getElementById('root');
// createRoot returns a handle, not an element
const root = createRoot(container);
root.render(<App />);
// Later, to tear the whole tree down (tests, widgets, micro-frontends)
// root.unmount();
// react-dom also exposes the server entry point:
// import { renderToString } from 'react-dom/server';