1.0.6 • Published 6 months ago

use-awesome-click-outside v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

useClickOutside custom hook

a simple custom hook to check when the user click outside an specified component

Installation

Install it from npm with your favorite package manager!

npm install use-awesome-click-outside

or:

yarn add use-awesome-click-outside

or:

pnpm install use-awesome-click-outside

usage

   import { useClickOutside } from 'use-awesome-click-outside';

   export const Component = () => {
   // pass the type of the HTML you will use here!
   const ref = useClickOutside<HTMLDivElement>(() => console.log('clicked outside!'));
   return (
    <div ref={ref}>
      <h1>Hello World! 🫡</h1>
    </div>
  );
};

Deep into the hook

this hook return the ref that you will need to pass on your html, this ref will check if the user is clicking outside the HTML, if it is re will call the function that you pass as parameter

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago