createRoot
The React DOM function that turns a page element into a React root, whose render method then displays a component inside it.
In more detail
createRoot enables the concurrent features of React 18 and later. Call it once per root container, then call root.render with your top component; root.unmount removes everything again.
Example
createRoot(document.getElementById("root")).render(<App />);Related terms
- root container — The existing page element, often <div id="root">, into which React renders an application.
- React DOM — The package that connects React to a web page, turning React elements into real browser page elements.
- hydration — The step where React in the browser attaches event handlers and state to HTML that was already rendered on the server.
Taught in
- State with useState: Immutability And Asynchronous Batching — React 19 & Modern Component Architecture
- Keys In Depth: Identity Preservation And Identity Resetting — React 19 & Modern Component Architecture
- Diffing Algorithm: Element Type Shifts And Subtree Tear Down — React 19 & Modern Component Architecture
- SyntheticEvent System: Event Delegation in Modern React — React 19 & Modern Component Architecture
- useEffect Lifecycle: Mount, Dependencies, And Cleanup Phases — React 19 & Modern Component Architecture
- Avoiding Effect Antipatterns: Derived State And Events — React 19 & Modern Component Architecture
- useLayoutEffect vs useEffect: Painting And Synchronous Reads — React 19 & Modern Component Architecture
- useRef Mechanics: DOM References And Mutable Persistent State — React 19 & Modern Component Architecture
- useImperativeHandle: Controlled Ref Forwarding Boundaries — React 19 & Modern Component Architecture
- Lifting State Up: Colocation, Ownership, And Data Flow — React 19 & Modern Component Architecture