import { VNode } from 'preact' import { useEffect, useRef } from 'preact/hooks' export default function MoreBox({ children }: { children: VNode | VNode[] }) { const dialog = useRef(null) useEffect(() => { dialog.current?.addEventListener('click', (event) => { if (event.target === dialog.current) { dialog.current?.close() } }) }, []) return ( <> {children} ) }