useDocumentEvent ​
Hook attaches an event listener to the document object for the specified event
typescript
import { useDocumentEvent } from '@siberiacancode/reactuse';
Usage ​
typescript
useDocumentEvent('click', () => console.log('clicked'));
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
event | Event | - | The event to listen for. |
listener | (event: DocumentEventMap[Event]) => void | - | The callback function to be executed when the event is triggered |
options? | UseEventListenerOptions | - | The options for the event listener |