Skip to content

Latest commit

 

History

History
16 lines (11 loc) · 355 Bytes

use-portal.md

File metadata and controls

16 lines (11 loc) · 355 Bytes

usePortal

create a portal ref to create a portal and append it to the body.

Example

import { createPortal } from "react-dom";
import { usePortal } from "@casperiv/useful/hooks/usePortal";

const Component = () => {
  const portalRef = usePortal("myCoolId");

  return portalRef ? createPortal(<p>Hello world!</p>, portalRef) : null;
};