Edit in GitHubLog an issue

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.

See addEventListener()

Parameters

NameTypeDescription
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

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.