From e2c0f172573959e3806c510910577ebe2532bb17 Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Wed, 4 Oct 2023 07:55:03 +0200 Subject: [PATCH] [IMP] doc: improve documentation of useExternalListener closes odoo/owl#1530 --- doc/reference/hooks.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/reference/hooks.md b/doc/reference/hooks.md index c89e43f6b..7ea668f1f 100644 --- a/doc/reference/hooks.md +++ b/doc/reference/hooks.md @@ -190,12 +190,13 @@ will then be updated accordingly. ### `useExternalListener` The `useExternalListener` hook helps solve a very common problem: adding and removing -a listener on some target whenever a component is mounted/unmounted. For example, +a listener on some target whenever a component is mounted/unmounted. It takes a target +as its first argument, forwards the other arguments to `addEventListener`. For example, a dropdown menu (or its parent) may need to listen to a `click` event on `window` to be closed: ```js -useExternalListener(window, "click", this.closeMenu); +useExternalListener(window, "click", this.closeMenu, { capture: true }); ``` ### `useComponent`