From cbe8de300f65cb628ee90eead91f26f663b3876c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ian=20L=C3=A9tourneau?= Date: Mon, 30 Sep 2024 20:57:06 -0400 Subject: [PATCH] fix(qwik): use cleanup function to unmount --- content/3-lifecycle/2-on-unmount/qwik/Time.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/3-lifecycle/2-on-unmount/qwik/Time.tsx b/content/3-lifecycle/2-on-unmount/qwik/Time.tsx index 0e6ec3ea..6de0c812 100644 --- a/content/3-lifecycle/2-on-unmount/qwik/Time.tsx +++ b/content/3-lifecycle/2-on-unmount/qwik/Time.tsx @@ -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

Current time: {store.time}

;