Tsallaka zuwa abun ciki
Justice Tech School

Portals

createPortal renders children into another DOM node.

Example
import { createPortal } from "react-dom";
function Modal({ children }) {
  return createPortal(<div className="modal">{children}</div>, document.body);
}

Exercise

Render elsewhere.

(node, document.body)

Quiz Test

Why use a portal?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.