From 70151d8e1bc7602eef95db8e38a88fdd5c097176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ian=20L=C3=A9tourneau?= Date: Tue, 1 Oct 2024 03:46:11 -0400 Subject: [PATCH] fix(qwik): use cleanup function to unmount (#261) --- 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}

;