@ajeamme/use-click-outside
v1.0.0
Published
Made with create-react-library
Downloads
2
Readme
How to use
const Component = () => {
const rootRef = useRef<HTMLDivElement>()
const [isOpen, setIsOpen] = React.useState(false)
useClickOutside(isOpen, setIsOpen, rootRef)
return (
<div ref={rootRef}>
<button>{isOpen ? 'Open dropdown' : 'Close dropdown'}</button>
{isOpen && <MyDropdown />}
</div>
)
}