Browse Source

chore: warn NaN vnode key

Evan You 6 năm trước cách đây
mục cha
commit
31e37b417b
1 tập tin đã thay đổi với 5 bổ sung0 xóa
  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.