[IMP] doc: explicit useEffect first parameter

The `useEffect` has two parameters:
* The `effect` function
* The `computeDependencies` function

The `effect` function always take as parameters the result
 of the `computeDependencies` function.

Expliciting this allows to better understand the `useEffect`
behaviour and the following example in the doc:

```
useEffect(
    (el) => el && el.focus(),
    () => [ref.el]
  );
```
This commit is contained in:
Florent Dardenne - dafl@odoo
2022-09-09 19:34:00 +02:00
committed by Géry Debongnie
parent 6ef38676c4
commit d27455e9f2
+2 -1
View File
@@ -234,7 +234,8 @@ are defined by a function instead of just the dependencies.
The `useEffect` hook takes two function: the effect function and the dependency The `useEffect` hook takes two function: the effect function and the dependency
function. The effect function perform some task and return (optionally) a cleanup function. The effect function perform some task and return (optionally) a cleanup
function. The dependency function returns a list of dependencies. If any of these function. The dependency function returns a list of dependencies, these dependencies
are passed as parameters in the effect function . If any of these
dependencies changes, then the current effect will be cleaned up and reexecuted. dependencies changes, then the current effect will be cleaned up and reexecuted.
Here is an example without any dependencies: Here is an example without any dependencies: