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

Function validateChildKeys

code/redux/public/app.js:20842–20874  ·  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

20840 * @param {*} parentType node's parent's type.
20841 */
20842function validateChildKeys(node, parentType) {
20843 if (typeof node !== 'object') {
20844 return;
20845 }
20846 if (Array.isArray(node)) {
20847 for (var i = 0; i < node.length; i++) {
20848 var child = node[i];
20849 if (isValidElement(child)) {
20850 validateExplicitKey(child, parentType);
20851 }
20852 }
20853 } else if (isValidElement(node)) {
20854 // This element was passed in a valid location.
20855 if (node._store) {
20856 node._store.validated = true;
20857 }
20858 } else if (node) {
20859 var iteratorFn = getIteratorFn(node);
20860 if (typeof iteratorFn === 'function') {
20861 // Entry iterators used to provide implicit keys,
20862 // but now we print a separate warning for them later.
20863 if (iteratorFn !== node.entries) {
20864 var iterator = iteratorFn.call(node);
20865 var step = void 0;
20866 while (!(step = iterator.next()).done) {
20867 if (isValidElement(step.value)) {
20868 validateExplicitKey(step.value, parentType);
20869 }
20870 }
20871 }
20872 }
20873 }
20874}
20875
20876/**
20877 * 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