Răsfoiți Sursa

chore: warn NaN vnode key

Evan You 6 ani în urmă
părinte
comite
31e37b417b
1 a modificat fișierele cu 5 adăugiri și 0 ștergeri
  1. 5 0
      packages/runtime-core/src/vnode.ts

+ 5 - 0
packages/runtime-core/src/vnode.ts

@@ -383,6 +383,11 @@ function _createVNode(
     appContext: null
   }
 
+  // validate key
+  if (__DEV__ && vnode.key !== vnode.key) {
+    warn(`VNode created with invalid key (NaN). VNode type:`, vnode.type)
+  }
+
   normalizeChildren(vnode, children)
 
   // presence of a patch flag indicates this node needs patching on updates.