import Layout from '../../components/Layout' import { ComponentsSidebar } from '../../sidebars' import { Playground } from '../../components/Playground'; import SyntaxHighlighter from '../../components/SyntaxHighlighter'; export default function Portal() { return (

Best Practive

Portals are used for rendering parts of a React component tree into a different part of the DOM. This is particularly useful for UI components that need to appear over the top of other components.

Mount and unmount events will be fired when portal elements are added or removed. These events contain the type of element and its z-index. The events will be one of knkPortalMount or knkPortalUnmount. These constants (PORTAL_MOUNT_EVENT and PORTAL_UNMOUNT_EVENT) are exported from this package. The type of the event itself, PortalEvent is also exported from the package. Due to custom events not being entirely supported in IE11, we create a normal event and add a detail object manually to the event.

Example PortalEvent:

Usage

This example renders a <div /> and <h2 /> into a Portal.

(

Modal dialog heading

) `} />
) }