useWindowEvent ​
Hook attaches an event listener to the window object for the specified event
sensors
low
test coverage
Last changed: 9 minutes ago
Installation ​
Library
CLI
Manual
typescript
import { useWindowEvent } from '@siberiacancode/reactuse';Usage ​
typescript
useWindowEvent('click', () => console.log('clicked'));Demo ​
Api ​
Parameters
| Name | Type | Default | Note |
|---|---|---|---|
| event | Event | - | The event to listen for. |
| listener | (event: WindowEventMap[Event]) => void | - | The callback function to be executed when the event is triggered |
| options? | UseEventListenerOptions | - | The options for the event listener |
Returns
void
Type declaration ​
typescript
import type { UseEventListenerOptions } from '../useEventListener/useEventListener';Source ​
Source • DemoContributors ​
D
H
A