Home / Function/ createPortal() — react Function Reference

createPortal() — react Function Reference

Architecture documentation for the createPortal() function in ReactDOM.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  d8f2f2c0_d99a_5498_f13d_46e185147bc0["createPortal()"]
  ca23127c_62b0_2c69_7293_39d92b24a5c0["ReactDOM.js"]
  d8f2f2c0_d99a_5498_f13d_46e185147bc0 -->|defined in| ca23127c_62b0_2c69_7293_39d92b24a5c0
  style d8f2f2c0_d99a_5498_f13d_46e185147bc0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-dom/src/shared/ReactDOM.js lines 56–68

function createPortal(
  children: ReactNodeList,
  container: Element | DocumentFragment,
  key: ?string = null,
): React$Portal {
  if (!isValidContainer(container)) {
    throw new Error('Target container is not a DOM element.');
  }

  // TODO: pass ReactDOM portal implementation as third argument
  // $FlowFixMe[incompatible-return] The Flow type is opaque but there's no way to actually create it.
  return createPortalImpl(children, container, null, key);
}

Domain

Subdomains

Frequently Asked Questions

What does createPortal() do?
createPortal() is a function in the react codebase, defined in packages/react-dom/src/shared/ReactDOM.js.
Where is createPortal() defined?
createPortal() is defined in packages/react-dom/src/shared/ReactDOM.js at line 56.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free