Hook accepts 3 arguments:
handler– function that will be called on outside click
events– optional list of events that indicate outside click
nodes- optional list of nodes that should not trigger outside click event
Hook returns React
ref object that should be passed to element on which outside clicks should be captured.
By default, use-click-outside listens to
you can change these events by passing an array of events as second argument:
In some cases you may want to trigger outside
click event for multiple nodes, for example, when dropdown renders in portal.
To do so provide third argument with an array of nodes which should not trigger outside click event:
By default, use-click-outside returns
ref object with
as ref type does not matter in almost all cases. You can specify ref type by passing a type: