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

Function validateChildKeys

code/new-context-api/public/app.js:18859–18891  ·  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

18857 * @param {*} parentType node's parent's type.
18858 */
18859function validateChildKeys(node, parentType) {
18860 if (typeof node !== 'object') {
18861 return;
18862 }
18863 if (Array.isArray(node)) {
18864 for (var i = 0; i < node.length; i++) {
18865 var child = node[i];
18866 if (isValidElement(child)) {
18867 validateExplicitKey(child, parentType);
18868 }
18869 }
18870 } else if (isValidElement(node)) {
18871 // This element was passed in a valid location.
18872 if (node._store) {
18873 node._store.validated = true;
18874 }
18875 } else if (node) {
18876 var iteratorFn = getIteratorFn(node);
18877 if (typeof iteratorFn === 'function') {
18878 // Entry iterators used to provide implicit keys,
18879 // but now we print a separate warning for them later.
18880 if (iteratorFn !== node.entries) {
18881 var iterator = iteratorFn.call(node);
18882 var step = void 0;
18883 while (!(step = iterator.next()).done) {
18884 if (isValidElement(step.value)) {
18885 validateExplicitKey(step.value, parentType);
18886 }
18887 }
18888 }
18889 }
18890 }
18891}
18892
18893/**
18894 * 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