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

Function validateChildKeys

code/styling/public/app.js:19498–19530  ·  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

19496 * @param {*} parentType node's parent's type.
19497 */
19498function validateChildKeys(node, parentType) {
19499 if (typeof node !== 'object') {
19500 return;
19501 }
19502 if (Array.isArray(node)) {
19503 for (var i = 0; i < node.length; i++) {
19504 var child = node[i];
19505 if (isValidElement(child)) {
19506 validateExplicitKey(child, parentType);
19507 }
19508 }
19509 } else if (isValidElement(node)) {
19510 // This element was passed in a valid location.
19511 if (node._store) {
19512 node._store.validated = true;
19513 }
19514 } else if (node) {
19515 var iteratorFn = getIteratorFn(node);
19516 if (typeof iteratorFn === 'function') {
19517 // Entry iterators used to provide implicit keys,
19518 // but now we print a separate warning for them later.
19519 if (iteratorFn !== node.entries) {
19520 var iterator = iteratorFn.call(node);
19521 var step = void 0;
19522 while (!(step = iterator.next()).done) {
19523 if (isValidElement(step.value)) {
19524 validateExplicitKey(step.value, parentType);
19525 }
19526 }
19527 }
19528 }
19529 }
19530}
19531
19532/**
19533 * 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