MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / validateChildKeys

Function validateChildKeys

code/one-direction-data-flow/public/app.js:19371–19403  ·  view source on GitHub ↗

* Ensure that every element either is passed in a static location, in an * array with an explicit keys property defined, or in an object literal * with valid key property. * * @internal * @param {ReactNode} node Statically passed child of any type. * @param {*} parentType node's parent's type.

(node, parentType)

Source from the content-addressed store, hash-verified

19369 * @param {*} parentType node's parent's type.
19370 */
19371function validateChildKeys(node, parentType) {
19372 if (typeof node !== 'object') {
19373 return;
19374 }
19375 if (Array.isArray(node)) {
19376 for (var i = 0; i < node.length; i++) {
19377 var child = node[i];
19378 if (isValidElement(child)) {
19379 validateExplicitKey(child, parentType);
19380 }
19381 }
19382 } else if (isValidElement(node)) {
19383 // This element was passed in a valid location.
19384 if (node._store) {
19385 node._store.validated = true;
19386 }
19387 } else if (node) {
19388 var iteratorFn = getIteratorFn(node);
19389 if (typeof iteratorFn === 'function') {
19390 // Entry iterators used to provide implicit keys,
19391 // but now we print a separate warning for them later.
19392 if (iteratorFn !== node.entries) {
19393 var iterator = iteratorFn.call(node);
19394 var step = void 0;
19395 while (!(step = iterator.next()).done) {
19396 if (isValidElement(step.value)) {
19397 validateExplicitKey(step.value, parentType);
19398 }
19399 }
19400 }
19401 }
19402 }
19403}
19404
19405/**
19406 * Given an element, validate that its props follow the propTypes definition,

Callers 2

Calls 3

isValidElementFunction · 0.70
validateExplicitKeyFunction · 0.70
getIteratorFnFunction · 0.70

Tested by

no test coverage detected