Skip to content

Commit

Permalink
[IMP] doc: improve documentation of useExternalListener
Browse files Browse the repository at this point in the history
closes #1530
  • Loading branch information
sdegueldre authored and ged-odoo committed Oct 25, 2023
1 parent aa6a4a5 commit 398df54
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doc/reference/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit 398df54

Please sign in to comment.