← All notes

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

See also

Claims

Sources

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

Permanent ID: iil:note:pj3s1sqf

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.},
}

Markdown

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.

All artifact files (JSON index)

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.