From 5d40cc112d82bff79ea8f2bc2b4681965042d588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 13 Apr 2023 09:43:36 +0200 Subject: [PATCH] [DOC] remove old references to comp for useRef hook Going from owl 1.0 to 2.0, we removed the possibility of having a reference to a component. However, the documentation was not properly updated to reflect that. --- doc/reference/hooks.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/reference/hooks.md b/doc/reference/hooks.md index e86369e9..c89e43f6 100644 --- a/doc/reference/hooks.md +++ b/doc/reference/hooks.md @@ -112,17 +112,16 @@ of a component, rendered by Owl. It only work on a html element tagged by the ```xml
- + hello
``` -In this example, the component will be able to access the `div` and the component -`SubComponent` with the `useRef` hook: +In this example, the component will be able to access the `input` with the `useRef` hook: ```js class Parent extends Component { - inputRef = useRef("someComponent"); + inputRef = useRef("someInput"); someMethod() { // here, if component is mounted, refs are active: @@ -139,18 +138,18 @@ The `t-ref` directive also accepts dynamic values with string interpolation `t-component` directives). For example, ```xml -
+
``` Here, the references need to be set like this: ```js -this.ref1 = useRef("component_1"); -this.ref2 = useRef("component_2"); +this.ref1 = useRef("div_1"); +this.ref2 = useRef("div_2"); ``` References are only guaranteed to be active while the parent component is mounted. -If this is not the case, accessing `el` or `comp` on it will return `null`. +If this is not the case, accessing `el` on it will return `null`. ### `useSubEnv` and `useChildSubEnv`