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

Function validateChildKeys

code/composition/public/app.js:19636–19668  ·  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

19634 * @param {*} parentType node's parent's type.
19635 */
19636function validateChildKeys(node, parentType) {
19637 if (typeof node !== 'object') {
19638 return;
19639 }
19640 if (Array.isArray(node)) {
19641 for (var i = 0; i < node.length; i++) {
19642 var child = node[i];
19643 if (isValidElement(child)) {
19644 validateExplicitKey(child, parentType);
19645 }
19646 }
19647 } else if (isValidElement(node)) {
19648 // This element was passed in a valid location.
19649 if (node._store) {
19650 node._store.validated = true;
19651 }
19652 } else if (node) {
19653 var iteratorFn = getIteratorFn(node);
19654 if (typeof iteratorFn === 'function') {
19655 // Entry iterators used to provide implicit keys,
19656 // but now we print a separate warning for them later.
19657 if (iteratorFn !== node.entries) {
19658 var iterator = iteratorFn.call(node);
19659 var step = void 0;
19660 while (!(step = iterator.next()).done) {
19661 if (isValidElement(step.value)) {
19662 validateExplicitKey(step.value, parentType);
19663 }
19664 }
19665 }
19666 }
19667 }
19668}
19669
19670/**
19671 * 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