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

Function warnOnInvalidKey

code/event-handlers/public/app.js:8549–8578  ·  view source on GitHub ↗

* Warns if there is a duplicate or missing key

(child, knownKeys)

Source from the content-addressed store, hash-verified

8547 * Warns if there is a duplicate or missing key
8548 */
8549 function warnOnInvalidKey(child, knownKeys) {
8550 {
8551 if (typeof child !== 'object' || child === null) {
8552 return knownKeys;
8553 }
8554 switch (child.$$typeof) {
8555 case REACT_ELEMENT_TYPE:
8556 case REACT_PORTAL_TYPE:
8557 warnForMissingKey(child);
8558 var key = child.key;
8559 if (typeof key !== 'string') {
8560 break;
8561 }
8562 if (knownKeys === null) {
8563 knownKeys = new Set();
8564 knownKeys.add(key);
8565 break;
8566 }
8567 if (!knownKeys.has(key)) {
8568 knownKeys.add(key);
8569 break;
8570 }
8571 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());
8572 break;
8573 default:
8574 break;
8575 }
8576 }
8577 return knownKeys;
8578 }
8579
8580 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
8581 // 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