useClickOutside ​
Hook to handle click events outside the specified target element(s)
typescript
import { useClickOutside } from '@siberiacancode/reactuse';
Usage ​
typescript
useClickOutside(ref, () => console.log('click outside'));
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
target | Target | - | The target element(s) to detect outside clicks for |
callback | (event: Event) => void | - | The callback to execute when a click outside the target is detected |
Returns
Parameters
Name | Type | Default | Note |
---|---|---|---|
callback | (event: Event) => void | - | The callback to execute when a click outside the target is detected |