import { useEffect, useRef } from "react"; export default ({ isOpen, children, className, onClose }) => { const ref = useRef(null); useEffect(() => { if (isOpen) { ref.current.showModal(); if (onClose) { ref.current.addEventListener("close", onClose); } } else { ref.current.close(); } }, [isOpen]); return (
{children}
); };