MCPcopy Create free account
hub / github.com/Lucifier129/react-lite / validateExplicitKey

Function validateExplicitKey

examples/simple/react.js:9301–9313  ·  view source on GitHub ↗

* Warn if the element doesn't have an explicit key assigned to it. * This element is in an array. The array could grow and shrink or be * reordered. All children that haven't already been validated are required to * have a "key" property assigned to it. * * @internal * @param {ReactElement} el

(element, parentType)

Source from the content-addressed store, hash-verified

9299 * @param {*} parentType element's parent's type.
9300 */
9301function validateExplicitKey(element, parentType) {
9302 if (!element._store || element._store.validated || element.key != null) {
9303 return;
9304 }
9305 element._store.validated = true;
9306
9307 var addenda = getAddendaForKeyUse('uniqueKey', element, parentType);
9308 if (addenda === null) {
9309 // we already showed the warning
9310 return;
9311 }
9312 "development" !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
9313}
9314
9315/**
9316 * Shared warning and monitoring code for the key warnings.

Callers 1

validateChildKeysFunction · 0.85

Calls 2

getAddendaForKeyUseFunction · 0.85
warningFunction · 0.50

Tested by

no test coverage detected