use-click-outside
Detects click and touch events outside of given element
Import
Source
Docs
Package
Usage
API
use-click-outside
hook accepts 3 arguments:
handler
– function that is called on outside clickevents
– optional list of events that trigger outside click,['mousedown', 'touchstart']
by defaultnodes
- optional list of nodes that should not trigger outside click event
The hook returns a ref
object that must be passed to the element
based on which outside clicks should be captured.
Change events
By default, use-click-outside
listens to mousedown
and touchstart
events,
you can change these events by passing an array of events as second argument: