MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / warnOnInvalidKey

Function warnOnInvalidKey

code/composition/public/app.js:9357–9386  ·  view source on GitHub ↗

* Warns if there is a duplicate or missing key

(child, knownKeys)

Source from the content-addressed store, hash-verified

9355 * Warns if there is a duplicate or missing key
9356 */
9357 function warnOnInvalidKey(child, knownKeys) {
9358 {
9359 if (typeof child !== 'object' || child === null) {
9360 return knownKeys;
9361 }
9362 switch (child.$$typeof) {
9363 case REACT_ELEMENT_TYPE:
9364 case REACT_PORTAL_TYPE:
9365 warnForMissingKey(child);
9366 var key = child.key;
9367 if (typeof key !== 'string') {
9368 break;
9369 }
9370 if (knownKeys === null) {
9371 knownKeys = new Set();
9372 knownKeys.add(key);
9373 break;
9374 }
9375 if (!knownKeys.has(key)) {
9376 knownKeys.add(key);
9377 break;
9378 }
9379 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());
9380 break;
9381 default:
9382 break;
9383 }
9384 }
9385 return knownKeys;
9386 }
9387
9388 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
9389 // 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