Gitako/src/components/Portal.tsx
2019-11-10 15:06:53 +08:00

12 lines
305 B
TypeScript

import * as React from 'react'
import * as ReactDOM from 'react-dom'
type Props = {
into: Element | null
}
export function Portal(props: React.PropsWithChildren<Props>) {
const { into, children } = props
if (!(into instanceof Element)) return null
return ReactDOM.createPortal(children, into)
}