use-event-listener
Subscribes to events of a given element with a ref
Source
Docs
PackageIcon
Usage
The use-event-listener hook adds a given event listener to an element to which ref is assigned.
The hook supports the same options as the addEventListener method.
After the component is unmounted, the listener is automatically removed.