From 5a0a2bfa9b563740d0c9ac192d993fe7edfbc00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Thu, 30 May 2024 21:46:51 +0800 Subject: [PATCH] refactor: remove optional chaining --- packages/reactivity/src/baseWatch.ts | 4 ++-- packages/runtime-core/src/componentOptions.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/reactivity/src/baseWatch.ts b/packages/reactivity/src/baseWatch.ts index eea988798..2b1c64dd2 100644 --- a/packages/reactivity/src/baseWatch.ts +++ b/packages/reactivity/src/baseWatch.ts @@ -215,13 +215,13 @@ export function baseWatch( const _cb = cb cb = (...args) => { _cb(...args) - effect?.stop() + effect.stop() } } else { const _getter = getter getter = () => { _getter() - effect?.stop() + effect.stop() } } } diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index 8196a8239..be0b20f84 100644 --- a/packages/runtime-core/src/componentOptions.ts +++ b/packages/runtime-core/src/componentOptions.ts @@ -842,7 +842,9 @@ export function createWatcher( const options: WatchOptions = {} if (__COMPAT__) { const instance = - getCurrentScope() === currentInstance?.scope ? currentInstance : null + currentInstance && getCurrentScope() === currentInstance.scope + ? currentInstance + : null const newValue = getter() if (