From d27455e9f226f8c141d7d86cc55f440d47966847 Mon Sep 17 00:00:00 2001 From: "Florent Dardenne - dafl@odoo" <109217759+fdardenne@users.noreply.github.com> Date: Fri, 9 Sep 2022 19:34:00 +0200 Subject: [PATCH] [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] ); ``` --- doc/reference/hooks.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/reference/hooks.md b/doc/reference/hooks.md index 0e544faa..e86369e9 100644 --- a/doc/reference/hooks.md +++ b/doc/reference/hooks.md @@ -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 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. Here is an example without any dependencies: