React-popper: Investigate new portals in React 16

Created on 26 Sep 2017  路  6Comments  路  Source: popperjs/react-popper

It would be cool if we could make this really easy and have a prop that passes down the id of a container or something similar to render <Popper/> components into.

Most helpful comment

I'm already using react-popper with React 16's portals:

With a simple 'Portal' component:

class Portal extends React.Component {
    render() {
        const { children, target = document.body } = this.props;
        return ReactDOM.createPortal(children, target);
    }
}

You can simply do:

<Manager tag={false}>
    <Target>
        <div>This target...</div>
    </Target>
    <Popper>
        <Portal>
            <div>... has this popper</div>
        </Portal>
    </Popper>
</Manager>

All 6 comments

I wouldn't add too much functionalities here honestly. I like specialized components

Would it be possible to first update to react 16 before going into this?

For React 16 I did prepare a small test PR while it was still in beta.

https://github.com/souporserious/react-popper/pull/43

Just FYI, reactstrap uses react-popper and did something similar (wasn't that hard), though I wouldn't use the new portals exclusively or you will break backwards compatibility which is :cry:. Maybe another library/component which depends on react-popper can be created which just adds this feature (like react-popper-portal).

I'm already using react-popper with React 16's portals:

With a simple 'Portal' component:

class Portal extends React.Component {
    render() {
        const { children, target = document.body } = this.props;
        return ReactDOM.createPortal(children, target);
    }
}

You can simply do:

<Manager tag={false}>
    <Target>
        <div>This target...</div>
    </Target>
    <Popper>
        <Portal>
            <div>... has this popper</div>
        </Portal>
    </Popper>
</Manager>

After thinking about it, I agree it shouldn't go in here since it's so trivial and would break backwards compatibility 馃挬

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clintharris picture clintharris  路  6Comments

souporserious picture souporserious  路  5Comments

sajcics picture sajcics  路  3Comments

linusthe3rd picture linusthe3rd  路  4Comments

souporserious picture souporserious  路  5Comments