Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/runtime-core/src/apiWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {
Ref,
ComputedRef,
ReactiveEffectOptions,
isReactive
isReactive,
pauseTracking,
resetTracking
} from '@vue/reactivity'
import { SchedulerJob, queuePreFlushCb } from './scheduler'
import {
Expand Down Expand Up @@ -249,6 +251,9 @@ function doWatch(
// watch(source, cb)
const newValue = runner()
if (deep || forceTrigger || hasChanged(newValue, oldValue)) {
// ref #2728
// disable deps collection in watch callbacks
pauseTracking()
// cleanup before running cb again
if (cleanup) {
cleanup()
Expand All @@ -259,6 +264,7 @@ function doWatch(
oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
onInvalidate
])
resetTracking()
oldValue = newValue
}
} else {
Expand Down