0.1.1 • Published 9 months ago

use-on-click-away v0.1.1

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

useOnClickAway

It's a 12kb React custom hook that catches clicks outside of the element it is applied to.

Installation

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

Example

use-on-click-away-demo

Usage

const MyComponent = () => {
  const ref = useRef()

  useOnClickAway(ref, () => {
    console.log('clicked away')
  })

  return (
    <div ref={ref}>
      ...
    </div>
  )

}

export default MyComponent

Contributing

You can contribute by opening an issue or sending a pull request.

License

This project is licensed under the MIT License.

0.1.0

9 months ago

0.1.1

9 months ago

0.0.2

2 years ago

0.0.1

2 years ago