@shevsky/via-portal

import { viaPortal } from '@shevsky/via-portal'; import React, { PropsWithChildren } from 'react';

Usage no npm install needed!

<script type="module">
  import shevskyViaPortal from 'https://cdn.skypack.dev/@shevsky/via-portal';
</script>

README

Wrap components to portal

Example

import { viaPortal } from '@shevsky/via-portal';
import React, { PropsWithChildren } from 'react';

type TFooProps = PropsWithChildren<{}>;

export const Foo = viaPortal((props: TFooProps): JSX.Element => {
  return (
    <div className="foo">
      {props.children}
    </div>
  );
}, 'foo'); // Would be rendered to <div data-foo-portal/> at the end of <body/>