diff --git a/content/2-templating/5-dom-ref/qwik/InputFocused.tsx b/content/2-templating/5-dom-ref/qwik/InputFocused.tsx index 67cd9202..b3839ad3 100644 --- a/content/2-templating/5-dom-ref/qwik/InputFocused.tsx +++ b/content/2-templating/5-dom-ref/qwik/InputFocused.tsx @@ -1,9 +1,12 @@ -import { component$, useVisibleTask$, useRef } from "@builder.io/qwik"; +import { component$, useVisibleTask$, useSignal } from "@builder.io/qwik"; export const InputFocused = component$(() => { - const inputElement = useRef(null); - - useVisibleTask$(() => inputElement.current.focus()); + const inputElement = useSignal(); + + useVisibleTask$(({ track }) => { + const el = track(inputElement); + el?.focus(); + }); return ; });