useEventListener()
A React Hook that gives you the ability to add a callback function when an event is triggered on an object.
This function attaches an event listener to a target object on mount and removes the listener on unmount.
Parameters
Name | Type | Description |
---|---|---|
target | EventTarget | The EventTarget to attach the listener to |
type | String | The type of Event to listen for, e.g. 'resize', 'error', etc. |
listener | function | A callback function that is invoked when the event is triggered |
...rest | any | Any other arguments to pass to the addEventListener() function |
Source Code: pwa-studio/packages/peregrine/lib/hooks/useEventListener.js