MCPcopy
hub / github.com/facebook/react / validateChildKeys

Function validateChildKeys

packages/react/src/jsx/ReactJSXElement.js:799–817  ·  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)

Source from the content-addressed store, hash-verified

797 * @param {*} parentType node's parent's type.
798 */
799function validateChildKeys(node) {
800 if (__DEV__) {
801 // Mark elements as being in a valid static child position so they
802 // don't need keys.
803 if (isValidElement(node)) {
804 if (node._store) {
805 node._store.validated = 1;
806 }
807 } else if (isLazyType(node)) {
808 if (node._payload.status === 'fulfilled') {
809 if (isValidElement(node._payload.value) && node._payload.value._store) {
810 node._payload.value._store.validated = 1;
811 }
812 } else if (node._store) {
813 node._store.validated = 1;
814 }
815 }
816 }
817}
818
819/**
820 * Verifies the object is a ReactElement.

Callers 3

jsxDEVImplFunction · 0.70
createElementFunction · 0.70
cloneElementFunction · 0.70

Calls 2

isLazyTypeFunction · 0.85
isValidElementFunction · 0.70

Tested by

no test coverage detected