source: src/components/custom-popover/use-popover.ts@ 5d6f37a

main
Last change on this file since 5d6f37a was 5d6f37a, checked in by Naum Shapkarovski <naumshapkarovski@…>, 7 weeks ago

add customer

  • Property mode set to 100644
File size: 693 bytes
Line 
1import { useCallback, useState } from 'react';
2
3// ----------------------------------------------------------------------
4
5type ReturnType = {
6 onClose: VoidFunction;
7 open: HTMLElement | null;
8 onOpen: (event: React.MouseEvent<HTMLElement>) => void;
9 setOpen: React.Dispatch<React.SetStateAction<HTMLElement | null>>;
10};
11
12export default function usePopover(): ReturnType {
13 const [open, setOpen] = useState<HTMLElement | null>(null);
14
15 const onOpen = useCallback((event: React.MouseEvent<HTMLElement>) => {
16 setOpen(event.currentTarget);
17 }, []);
18
19 const onClose = useCallback(() => {
20 setOpen(null);
21 }, []);
22
23 return {
24 open,
25 onOpen,
26 onClose,
27 setOpen,
28 };
29}
Note: See TracBrowser for help on using the repository browser.