MCPcopy Create free account
hub / github.com/Lobos/react-ui / validateChildKeys

Function validateChildKeys

docs/lib/react.js:10302–10333  ·  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

10300 * @param {*} parentType node's parent's type.
10301 */
10302function validateChildKeys(node, parentType) {
10303 if (typeof node !== 'object') {
10304 return;
10305 }
10306 if (Array.isArray(node)) {
10307 for (var i = 0; i < node.length; i++) {
10308 var child = node[i];
10309 if (ReactElement.isValidElement(child)) {
10310 validateExplicitKey(child, parentType);
10311 }
10312 }
10313 } else if (ReactElement.isValidElement(node)) {
10314 // This element was passed in a valid location.
10315 if (node._store) {
10316 node._store.validated = true;
10317 }
10318 } else if (node) {
10319 var iteratorFn = getIteratorFn(node);
10320 // Entry iterators provide implicit keys.
10321 if (iteratorFn) {
10322 if (iteratorFn !== node.entries) {
10323 var iterator = iteratorFn.call(node);
10324 var step;
10325 while (!(step = iterator.next()).done) {
10326 if (ReactElement.isValidElement(step.value)) {
10327 validateExplicitKey(step.value, parentType);
10328 }
10329 }
10330 }
10331 }
10332 }
10333}
10334
10335/**
10336 * Assert that the props are valid

Callers 1

react.jsFile · 0.85

Calls 3

validateExplicitKeyFunction · 0.85
getIteratorFnFunction · 0.85
nextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…