MCPcopy Create free account
hub / github.com/plotly/dash / warnOnInvalidKey

Function warnOnInvalidKey

dash/deps/react-dom@18.3.1.js:13512–13552  ·  view source on GitHub ↗

* Warns if there is a duplicate or missing key

(child, knownKeys, returnFiber)

Source from the content-addressed store, hash-verified

13510
13511
13512 function warnOnInvalidKey(child, knownKeys, returnFiber) {
13513 {
13514 if (typeof child !== 'object' || child === null) {
13515 return knownKeys;
13516 }
13517
13518 switch (child.$$typeof) {
13519 case REACT_ELEMENT_TYPE:
13520 case REACT_PORTAL_TYPE:
13521 warnForMissingKey(child, returnFiber);
13522 var key = child.key;
13523
13524 if (typeof key !== 'string') {
13525 break;
13526 }
13527
13528 if (knownKeys === null) {
13529 knownKeys = new Set();
13530 knownKeys.add(key);
13531 break;
13532 }
13533
13534 if (!knownKeys.has(key)) {
13535 knownKeys.add(key);
13536 break;
13537 }
13538
13539 error('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.', key);
13540
13541 break;
13542
13543 case REACT_LAZY_TYPE:
13544 var payload = child._payload;
13545 var init = child._init;
13546 warnOnInvalidKey(init(payload), knownKeys, returnFiber);
13547 break;
13548 }
13549 }
13550
13551 return knownKeys;
13552 }
13553
13554 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {
13555 // This algorithm can't optimize by searching from both ends since we

Callers 2

reconcileChildrenArrayFunction · 0.70

Calls 3

warnForMissingKeyFunction · 0.70
errorFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…