import { h, Fragment } from 'preact'; import { createPortal } from 'preact/compat'; import { useState, useEffect } from 'preact/hooks'; export default function LargeDialog({ children, portalRootID = 'dialogs' }) { const portalRoot = portalRootID && document.getElementById(portalRootID); const [show, setShow] = useState(false); useEffect(() => { window.requestAnimationFrame(() => { setShow(true); }); }, []); const dialog = (
{children}
); return portalRoot ? createPortal(dialog, portalRoot) : dialog; }