Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 566 Bytes

README.md

File metadata and controls

30 lines (24 loc) · 566 Bytes

react-portal - The real React Portal, not a ReactDOM Portal

Inject React node into any position in React tree.

Usage

import { usePortal, PortalIn } from '@-ft/react-portal';

function MyPage({ children }) {
  const { append, PortalOut } = usePortal();

  return (
    <Layout>
      <SomeOtherComponent>
        <MyComponent append={append} />
      </SomeOtherComponent>
      <PortalOut />
    </Layout>
  );
}

function MyComponent({ append }) {
  return (
    <PortalIn append={append}>
      <DirectBottomOfLayout />
    </PortalIn>
  );
}