addWindowListener
Commons
stable
Register an event listener on window and push its cleanup function into an array collected on unmount. Returns a standalone remove callback for manual teardown.
API
Signature
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- eventrequisstring
- The DOM event type to listen for, e.g. "resize" or "scroll".
- listenerrequisEventListenerOrEventListenerObject
- The event handler callback or object with a handleEvent method.
- onUnmountedCleanupFnsany[]
- Optional array that collects cleanup functions automatically called when the component unmounts.
API
Valeur de retour
La valeur retournée par cet util.
- A function that removes the listener from window and splices its entry out of onUnmountedCleanupFns.
Usage
Exemples
Extraits de code prêts à coller.
Listen to resize with automatic cleanup