From f8ea946ef7615d9bc131104c2fdcf8e08501add4 Mon Sep 17 00:00:00 2001 From: Yang Mingshan Date: Sun, 31 Dec 2023 00:52:34 +0800 Subject: [PATCH] fix(watch): replace instance unmounted with scope inactive --- packages/runtime-core/src/apiWatch.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/runtime-core/src/apiWatch.ts b/packages/runtime-core/src/apiWatch.ts index d840864454f..fdd2125c044 100644 --- a/packages/runtime-core/src/apiWatch.ts +++ b/packages/runtime-core/src/apiWatch.ts @@ -220,8 +220,8 @@ function doWatch( ) } - const instance = - getCurrentScope() === currentInstance?.scope ? currentInstance : null + const scope = getCurrentScope() + const instance = currentInstance const reactiveGetter = (source: object) => deep === true ? source // traverse will happen in wrapped getter below @@ -261,7 +261,7 @@ function doWatch( } else { // no cb -> simple effect getter = () => { - if (instance && instance.isUnmounted) { + if (scope && !scope.active) { return } if (cleanup) {