import { SubMenu } from '@szhsin/react-menu'; import { useRef } from 'preact/hooks'; export default function SubMenu2(props) { const menuRef = useRef(); return ( { if (e.pointerType === 'touch') { menuRef.current?.openMenu?.(); } }, onPointerLeave: (e) => { if (e.pointerType === 'touch') { menuRef.current?.openMenu?.(); } }, }} /> ); }