import { useCallback, useState } from 'react'; // ---------------------------------------------------------------------- type ReturnType = { onClose: VoidFunction; open: HTMLElement | null; onOpen: (event: React.MouseEvent) => void; setOpen: React.Dispatch>; }; export default function usePopover(): ReturnType { const [open, setOpen] = useState(null); const onOpen = useCallback((event: React.MouseEvent) => { setOpen(event.currentTarget); }, []); const onClose = useCallback(() => { setOpen(null); }, []); return { open, onOpen, onClose, setOpen, }; }