import { type ContainerNode, type FunctionComponent } from 'preact'
import { createPortal } from 'preact/compat'

const Portal: FunctionComponent<{ container?: ContainerNode }> = ({
  children,
  container = typeof document !== 'undefined' && document.body,
}) => container && createPortal(children, container)

export default Portal
