MCPcopy Create free account
hub / github.com/microsoft/SandDance / validateChildKeys

Function validateChildKeys

docs/external/js/react.development.js:1837–1873  ·  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 pa

(node, parentType)

Source from the content-addressed store, hash-verified

1835
1836
1837 function validateChildKeys(node, parentType) {
1838 if (typeof node !== 'object') {
1839 return;
1840 }
1841
1842 if (Array.isArray(node)) {
1843 for (var i = 0; i < node.length; i++) {
1844 var child = node[i];
1845
1846 if (isValidElement(child)) {
1847 validateExplicitKey(child, parentType);
1848 }
1849 }
1850 } else if (isValidElement(node)) {
1851 // This element was passed in a valid location.
1852 if (node._store) {
1853 node._store.validated = true;
1854 }
1855 } else if (node) {
1856 var iteratorFn = getIteratorFn(node);
1857
1858 if (typeof iteratorFn === 'function') {
1859 // Entry iterators used to provide implicit keys,
1860 // but now we print a separate warning for them later.
1861 if (iteratorFn !== node.entries) {
1862 var iterator = iteratorFn.call(node);
1863 var step;
1864
1865 while (!(step = iterator.next()).done) {
1866 if (isValidElement(step.value)) {
1867 validateExplicitKey(step.value, parentType);
1868 }
1869 }
1870 }
1871 }
1872 }
1873 }
1874 /**
1875 * Given an element, validate that its props follow the propTypes definition,
1876 * provided by the type.

Callers 2

Calls 3

isValidElementFunction · 0.85
validateExplicitKeyFunction · 0.85
getIteratorFnFunction · 0.70

Tested by

no test coverage detected