Skip to content

Commit

Permalink
Wrap function in cleanup function instead of returning it
Browse files Browse the repository at this point in the history
  • Loading branch information
thasmo authored Nov 14, 2023
1 parent 0c7c7e6 commit 8502210
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { component$, useVisibleTask$, useSignal } from '@builder.io/qwik';

export default component$(() => {
const aHref = useSignal<Element>();
useVisibleTask$(() => {
useVisibleTask$(({cleanup}) => {
const handler = (event: Event) => {
event.preventDefault();
window.open('http://qwik.builder.io');
};
aHref.value!.addEventListener('click', handler);
return () => aHref.value!.removeEventListener('click', handler);
cleanup(() => aHref.value!.removeEventListener('click', handler));
});

return (
Expand Down

0 comments on commit 8502210

Please sign in to comment.