MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / warnOnInvalidKey

Function warnOnInvalidKey

code/redux/public/app.js:9470–9499  ·  view source on GitHub ↗

* Warns if there is a duplicate or missing key

(child, knownKeys)

Source from the content-addressed store, hash-verified

9468 * Warns if there is a duplicate or missing key
9469 */
9470 function warnOnInvalidKey(child, knownKeys) {
9471 {
9472 if (typeof child !== 'object' || child === null) {
9473 return knownKeys;
9474 }
9475 switch (child.$$typeof) {
9476 case REACT_ELEMENT_TYPE:
9477 case REACT_PORTAL_TYPE:
9478 warnForMissingKey(child);
9479 var key = child.key;
9480 if (typeof key !== 'string') {
9481 break;
9482 }
9483 if (knownKeys === null) {
9484 knownKeys = new Set();
9485 knownKeys.add(key);
9486 break;
9487 }
9488 if (!knownKeys.has(key)) {
9489 knownKeys.add(key);
9490 break;
9491 }
9492 warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$2());
9493 break;
9494 default:
9495 break;
9496 }
9497 }
9498 return knownKeys;
9499 }
9500
9501 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
9502 // This algorithm can't optimize by searching from boths ends since we

Callers 2

reconcileChildrenArrayFunction · 0.70

Calls 2

warningFunction · 0.85
warnForMissingKeyFunction · 0.70

Tested by

no test coverage detected