瀏覽代碼

fix(runtime-core): avoid recursive warning

close #8074
Evan You 1 年之前
父節點
當前提交
3ee7b4c7b1
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      packages/runtime-core/src/warning.ts

+ 6 - 0
packages/runtime-core/src/warning.ts

@@ -30,7 +30,12 @@ export function popWarningContext() {
   stack.pop()
 }
 
+let isWarning = false
+
 export function warn(msg: string, ...args: any[]) {
+  if (isWarning) return
+  isWarning = true
+
   // avoid props formatting or warn handler tracking deps that might be mutated
   // during patch, leading to infinite recursion.
   pauseTracking()
@@ -70,6 +75,7 @@ export function warn(msg: string, ...args: any[]) {
   }
 
   resetTracking()
+  isWarning = false
 }
 
 export function getComponentTrace(): ComponentTraceStack {