acrool / acrool-react-portal

Throw React elements (ex: modal, dialog, toaster) to external using elements (usually used for

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Acrool React Portal

Throw React elements (ex: modal, dialog, toaster) to external using elements (usually used for

NPM npm npm

npm downloads npm

https://react.dev/reference/react-dom/createPortal

Features

  • Pass the component to the external Dom through the portal

Install

yarn add @acrool/react-portal

Usage

add in your App.tsx

import ReactPortal from '@acrool/react-portal';

const App = () => {
    return (
        <ReactPortal
            id="acrool-react-modal"
            className={styles.root}
        >
            {item && renderDialog()}
        </ReactPortal>
    );
};

There is also a example that you can play with it:

Play react-editext-example

Play react-editext-example

Play react-editext-example

License

MIT © Acrool & Imagine

About

Throw React elements (ex: modal, dialog, toaster) to external using elements (usually used for


Languages

Language:MDX 42.8%Language:TypeScript 33.8%Language:JavaScript 12.3%Language:CSS 7.0%Language:Shell 2.7%Language:HTML 1.4%