Skip to main content

React DOM visual mental model

React describes UI. React DOM is the renderer that connects React's model to the browser DOM.

React core → React DOM → browser
ReactComponent and rendering model

Components, Hooks, state, Context, Suspense, transitions, and element descriptions live in React's programming model.

React DOMBrowser renderer

React DOM knows how React elements map to DOM nodes, browser events, forms, hydration, portals, and DOM-specific APIs.

BrowserReal platform behaviour

HTML semantics, focus, layout, paint, CSS, accessibility APIs, events, and the actual DOM remain browser responsibilities.

Portals change DOM placement, not React ownership​

Portal mental model
React treeOwnership stays with the parent

Context, React event propagation, and component ownership follow the React tree.

DOM treeRendered node can live elsewhere

A modal or tooltip can be inserted into a separate DOM container using a portal.

Portal example architecture
App → Dialog component
React still owns Dialog in App tree
#modal-root receives the actual DOM nodes

flushSync is an escape hatch​

Normal scheduling vs flushSync
DefaultLet React schedule updates

React can batch and coordinate work for responsiveness and consistency.

Escape hatchflushSync forces a synchronous boundary

Use only when an external/browser API requires the DOM to be updated before the next imperative step.

React DOM does not replace the platform​

Semantic HTML

Use native elements for built-in meaning, keyboard behaviour, and accessibility.

Custom elements

React DOM can interoperate with web components, but their contracts remain platform contracts.

SVG and DOM props

React DOM maps React props onto host-specific DOM/SVG behaviour.

Choose the boundary intentionally​

Is this a React problem or a browser-renderer problem?
State, Hooks, Context, component compositionReact core mental model.
DOM nodes, forms, portals, hydration, browser eventsReact DOM / browser boundary.
Focus, layout, CSS, native semanticsUnderstand the browser platform first.
Need DOM updated synchronously for an imperative integrationConsider flushSync only as a narrow escape hatch.
Need visual content outside normal DOM hierarchyConsider a portal while preserving React ownership.

Keep this mental model​

React DOM in one picture
React calculates UI
React DOM commits browser host changes
The browser lays out, paints, focuses, and exposes platform behaviour

Continue with Portals and flushSync for the detailed browser-renderer APIs.