It's a 6kb
React custom hook that catches clicks outside of the element it is applied to.
use-on-click-away is available as an npm package.
To install it, run:
//with npm npm install use-on-click-away //with yarn yarn add use-on-click-away
const MyComponent = () => { const ref = useRef() useOnClickAway(ref, () => { console.log('clicked away') }) return ( <div ref={ref}> ... </div> ) } export default MyComponent
You can contribute by opening an issue or sending a pull request.
This project is licensed under the MIT License.