Skip to content

Commit

Permalink
fix(qwik): use cleanup function to unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
ianlet authored Oct 1, 2024
1 parent 0441bc9 commit cbe8de3
Showing 1 changed file with 2 additions and 2 deletions.
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
Expand Up @@ -5,12 +5,12 @@ export const App = component$(() => {
time: new Date().toLocaleTimeString(),
});

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

return () => clearInterval(timer);
cleanup(() => clearInterval(timer));
});

return <p>Current time: {store.time}</p>;
Expand Down

0 comments on commit cbe8de3

Please sign in to comment.