React has recently added Portal feature, effectively ripping a sub-tree of virtual DOM out and placing it elsewhere in 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,
);
}
Documentation is not clear if each portal must live in its own domNode
.
NOTE: the current implementation as of 11-Feb-2017 does allow multiple portals hosted inside single domNode
. Here's a fork of original CodePlex demo from React's docs, pushing two portals into one parent node:
https://codepen.io/anon/pen/WXYNpE
But is this an implementation quirk, or by design?
As you can see in mentioned codepen, multiple Portals are appended to domNode (e.g. inside this node). Personally this implementation do not bother me, and as i understand this is by design and not a quirk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With