React createPortal: render children into another DOM node
Answer: createPortal lets you render some children into a different part of the DOM. Import createPortal from react-dom. A portal only changes the physical placement of the DOM node. Events bubble up from children to parents according to the React tree.
Examples
import { createPortal } from 'react-dom';
export function Dialog({ children }) {
return createPortal(children, document.body);
}
Notes
Context is still provided by the parent tree. Portals are useful for a modal dialog or for rendering into document.body.
Reference list
createPortalrenders children into a different part of the DOM.ImportcreatePortal from react-dom.Eventsbubble according to the React tree, not only the DOM tree.
See also
Claims
- id: C1 claim: createPortal renders children into a different part of the DOM. source: S1 evidence: "lets you render some children into a different part of the DOM"
- id: C2 claim: Import createPortal from react-dom. source: S2 evidence: "import { createPortal } from 'react-dom'"
- id: C3 claim: Events bubble according to the React tree, not only the DOM tree. source: S2 evidence: "events bubble up from children to parents according to the React tree"
Sources
- [S1] createPortal. React docs. https://react.dev/reference/react-dom/createPortal . License: CC-BY-4.0. Accessed 2026-11-18.
- [S2] createPortal.md. reactjs/react.dev. https://github.com/reactjs/react.dev/blob/main/src/content/reference/react-dom/createPortal.md . License: CC-BY-4.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: React docs, createPortal; reactjs/react.dev, createPortal.md. CC-BY-4.0 (https://raw.githubusercontent.com/reactjs/react.dev/main/LICENSE-DOCS.md). Copyright Meta Platforms, Inc. and affiliates. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: React docs, createPortal; reactjs/react.dev, createPortal.md. CC-BY-4.0 (https://raw.githubusercontent.com/reactjs/react.dev/main/LICENSE-DOCS.md). Copyright Meta Platforms, Inc. and affiliates.
Cite this
iinventedlight. 2026. "React createPortal: render children into another DOM node." iinventedlight Library, iil:note:pj3s1sqf, version of 2026-11-18. https://iinventedlight.com/library/notes/react-portals/. License: CC-BY-4.0.
@misc{iil_note_pj3s1sqf,
author = {{iinventedlight}},
title = {{React createPortal: render children into another DOM node}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/react-portals/},
note = {Permanent ID iil:note:pj3s1sqf. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- react-portals.table.json (table; CC-BY-4.0)
- react-portals.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/react-portals.md.