Gitako/src/components/Portal.tsx
2024-09-23 21:40:02 +08:00

12 lines
300 B
TypeScript

import 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)
}