Skip to content

Commit

Permalink
chore: fix vitest-dev#335
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Feb 20, 2021
1 parent 9dcb90f commit 00668d7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/useEventListener/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function useEventListener(...args: any[]) {

let cleanup = noop

watch(
const stopWatch = watch(
() => unref(target),
(el) => {
cleanup()
Expand All @@ -115,6 +115,11 @@ export function useEventListener(...args: any[]) {
{ immediate: true },
)

const stop = () => {
stopWatch()
cleanup()
}

tryOnUnmounted(stop)

return stop
Expand Down

0 comments on commit 00668d7

Please sign in to comment.