Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

component-portal

robertpanvip19ISC1.0.1TypeScript support: included

component for rendering the spec dom

react, react-component, portal

readme

📦 Installation

npm install component-portal

🔨 Usage

class Test extends React.PureComponent {

    state = {
    };
    ref=React.createRef<HTMLDivElement>()
    render() {
        const {} = this.state;
        return (
            <div>
                <Portal getContainer={()=>this.ref.current}>123</Portal>
                <div ref={this.ref}>456</div>
                <div id='container'>789</div>
                <Portal getContainer={'#container'}>123</Portal>
            </div>
        );
    }
}