mirror of
https://github.com/lainbo/component-party.git
synced 2026-04-05 13:09:03 +08:00
fix(qwik): use cleanup function to unmount (#261)
This commit is contained in:
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user