* Warns if there is a duplicate or missing key
(child, knownKeys)
| 8450 | * Warns if there is a duplicate or missing key |
| 8451 | */ |
| 8452 | function warnOnInvalidKey(child, knownKeys) { |
| 8453 | { |
| 8454 | if (typeof child !== 'object' || child === null) { |
| 8455 | return knownKeys; |
| 8456 | } |
| 8457 | switch (child.$$typeof) { |
| 8458 | case REACT_ELEMENT_TYPE: |
| 8459 | case REACT_PORTAL_TYPE: |
| 8460 | warnForMissingKey(child); |
| 8461 | var key = child.key; |
| 8462 | if (typeof key !== 'string') { |
| 8463 | break; |
| 8464 | } |
| 8465 | if (knownKeys === null) { |
| 8466 | knownKeys = new Set(); |
| 8467 | knownKeys.add(key); |
| 8468 | break; |
| 8469 | } |
| 8470 | if (!knownKeys.has(key)) { |
| 8471 | knownKeys.add(key); |
| 8472 | break; |
| 8473 | } |
| 8474 | 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()); |
| 8475 | break; |
| 8476 | default: |
| 8477 | break; |
| 8478 | } |
| 8479 | } |
| 8480 | return knownKeys; |
| 8481 | } |
| 8482 | |
| 8483 | function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) { |
| 8484 | // This algorithm can't optimize by searching from boths ends since we |
no test coverage detected