If you have any project questions, concerns, or contribution ideas, join our #pwa Slack channel. Find out how to create an account by visiting Community Resources


useEventListener(target, type, listener, …rest)

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.

See addEventListener()

Kind: global function

Param 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

For implementation details View Source.