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

Function validateExplicitKey

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

10235 * @param {*} parentType element's parent's type.
10236 */
10237function validateExplicitKey(element, parentType) {
10238 if (!element._store || element._store.validated || element.key != null) {
10239 return;
10240 }
10241 element._store.validated = true;
10242
10243 var addenda = getAddendaForKeyUse('uniqueKey', element, parentType);
10244 if (addenda === null) {
10245 // we already showed the warning
10246 return;
10247 }
10248 "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 || '') : void 0;
10249}
10250
10251/**
10252 * Shared warning and monitoring code for the key warnings.

Callers 1

validateChildKeysFunction · 0.85

Calls 2

getAddendaForKeyUseFunction · 0.85
warningFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…