React recently added a Portal function, effectively breaking the subtree of the virtual DOM and placing it elsewhere in the physical DOM.
render() { // React does *not* create a new div. It renders the children into `domNode`. // `domNode` is any valid DOM node, regardless of its location in the DOM. return ReactDOM.createPortal( this.props.children, domNode, ); }
The documentation is fuzzy if each portal should live in its own domNode .
NOTE. The current version from February 11, 2017 allows several portals to be placed inside one domNode . Here's the fork of the original CodePlex demo from React docs, pushing two portals into one parent node:
https://codepen.io/anon/pen/WXYNpE
But is this a fad of implementation or design?
source share