mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] doc: improve documentation of useExternalListener
closes odoo/owl#1530
This commit is contained in:
committed by
Géry Debongnie
parent
aa6a4a5d46
commit
398df543fe
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user