瀏覽代碼

fix(runtime-core): prevent updating instance if it's already the current instance

daiwei 1 年之前
父節點
當前提交
ffbe87e7a3
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      packages/runtime-core/src/component.ts

+ 4 - 1
packages/runtime-core/src/component.ts

@@ -760,7 +760,10 @@ if (__SSR__) {
   }
 }
 
-export const setCurrentInstance = (instance: ComponentInternalInstance) => {
+export const setCurrentInstance = (
+  instance: ComponentInternalInstance,
+): (() => void) => {
+  if (currentInstance === instance) return NOOP
   const prev = currentInstance
   internalSetCurrentInstance(instance)
   instance.scope.on()