useEventListener
Adds and cleans up an event listener on a specified target element.
useEventListener
Installation
Usage
API
useEventListener
Adds an event listener to the target element.
Parameters
| Name | Type | Description | 
|---|---|---|
| eventName | K | The event type (e.g. 'click', 'scroll', 'resize', etc.). | 
| handler | (event: WindowEventMap[K]) => void | The event handler function. | 
| element | RefObject<HTMLElement> | Window | The target element to attach the event listener to. Default is window. | 
Returns
| Name | Type | Description | 
|---|---|---|
| undefined | void |