use-toggle-and-outclick
v1.1.0
Published
React hook for controlling the state of any dropdowns that need an outclick for closing
Downloads
27
Maintainers
Readme
use-toggle-and-outclick
React hook for controlling the state of any dropdowns that need an outclick for closing
Install
yarn add use-toggle-and-outclick
Usage
import useToggleAndOutClick from 'use-toggle-and-out-click';
const ExampleControl = () => {
const [isDropOpened, dropRef, toggleDrop, closeExplicitly] = useToggleAndOutClick();
/**
* isDropOpened - state field weather the dropdown is open now
* dropRef - ref for dropdown dom-node (ref={dropRef})
* toggleDrop - function that toggles state
* closeExplicitly - function that closes dropdown
*/
// ...
};