Skip to content

Commit

Permalink
feat(content): qwik update PageTitle.tsx (#224)
Browse files Browse the repository at this point in the history
* Update PageTitle.tsx

The API changed since this example was added. See QwikDev/qwik#3215 and https://qwik.dev/docs/components/tasks/#usevisibletask

* Change all occurrences of useClientEffect$
  • Loading branch information
hbendev authored Mar 5, 2024
1 parent 3d0b995 commit f4fa6ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions content/2-templating/5-dom-ref/qwik/InputFocused.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { component$, useClientEffect$, useRef } from "@builder.io/qwik";
import { component$, useVisibleTask$, useRef } from "@builder.io/qwik";

export const InputFocused = component$(() => {
const inputElement = useRef(null);

useClientEffect$(() => inputElement.current.focus());
useVisibleTask$(() => inputElement.current.focus());

return <input type="text" ref={inputElement} />;
});
4 changes: 2 additions & 2 deletions content/3-lifecycle/1-on-mount/qwik/PageTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { component$, useClientEffect$, useStore } from "@builder.io/qwik";
import { component$, useVisibleTask$, useStore } from "@builder.io/qwik";

export const App = component$(() => {
const store = useStore({
pageTitle: "",
});

useClientEffect$(() => {
useVisibleTask$(() => {
store.pageTitle = document.title;
});

Expand Down
4 changes: 2 additions & 2 deletions content/3-lifecycle/2-on-unmount/qwik/Time.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { component$, useClientEffect$, useStore } from "@builder.io/qwik";
import { component$, useVisibleTask$, useStore } from "@builder.io/qwik";

export const App = component$(() => {
const store = useStore({
time: new Date().toLocaleTimeString(),
});

useClientEffect$(() => {
useVisibleTask$(() => {
const timer = setInterval(() => {
store.time = new Date().toLocaleTimeString();
}, 1000);
Expand Down

0 comments on commit f4fa6ed

Please sign in to comment.