Skip to content

Commit

Permalink
fix: tracked in cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleSound committed Dec 27, 2023
1 parent b57405c commit a8dc8e6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/reactivity/src/baseWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
type DebuggerOptions,
type EffectScheduler,
ReactiveEffect,
pauseTracking,
resetTracking,
} from './effect'
import { isReactive, isShallow } from './reactive'
import { type Ref, isRef } from './ref'
Expand Down Expand Up @@ -179,7 +181,12 @@ export function baseWatch(
// no cb -> simple effect
getter = () => {
if (cleanup) {
cleanup()
pauseTracking()
try {
cleanup()
} finally {
resetTracking()
}
}
const currentEffect = activeEffect
activeEffect = effect
Expand Down

0 comments on commit a8dc8e6

Please sign in to comment.