use-toggle-and-outclick

1.1.0 • Public • Published

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
  */
 
  // ...
};

Examples

/use-toggle-and-outclick/

    Package Sidebar

    Install

    npm i use-toggle-and-outclick

    Weekly Downloads

    2

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    9.04 kB

    Total Files

    12

    Last publish

    Collaborators

    • limiter_core