Fragments and Portals
Slinky supports the special fragment and portal element types that were introduced in React 16.
Fragments
Fragments make it possible to return multiple elements from a component. To create a fragment simply return a list of elements in your render
method.
Additionally, Slinky supports the Fragment
component introduced in React 16.2.
Portals
Portals are another special element type introduced in React 16 that make it possible to render React content in a different location in the DOM than it would normally go. This is useful for components like modals, which often need to be placed at a higher level in the DOM than where the component is placed.
To construct a portal, use the method in ReactDOM
:
This will result in the h1
tag being rendered into the containerDOMNode button
tag instead of inside the parent div
tag.