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

Function validateChildKeys

code/dependency-injection/public/app.js:19591–19623  ·  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

19589 * @param {*} parentType node's parent's type.
19590 */
19591function validateChildKeys(node, parentType) {
19592 if (typeof node !== 'object') {
19593 return;
19594 }
19595 if (Array.isArray(node)) {
19596 for (var i = 0; i < node.length; i++) {
19597 var child = node[i];
19598 if (isValidElement(child)) {
19599 validateExplicitKey(child, parentType);
19600 }
19601 }
19602 } else if (isValidElement(node)) {
19603 // This element was passed in a valid location.
19604 if (node._store) {
19605 node._store.validated = true;
19606 }
19607 } else if (node) {
19608 var iteratorFn = getIteratorFn(node);
19609 if (typeof iteratorFn === 'function') {
19610 // Entry iterators used to provide implicit keys,
19611 // but now we print a separate warning for them later.
19612 if (iteratorFn !== node.entries) {
19613 var iterator = iteratorFn.call(node);
19614 var step = void 0;
19615 while (!(step = iterator.next()).done) {
19616 if (isValidElement(step.value)) {
19617 validateExplicitKey(step.value, parentType);
19618 }
19619 }
19620 }
19621 }
19622 }
19623}
19624
19625/**
19626 * 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