* Warns if there is a duplicate or missing key
(child, knownKeys)
| 8578 | * Warns if there is a duplicate or missing key |
| 8579 | */ |
| 8580 | function warnOnInvalidKey(child, knownKeys) { |
| 8581 | { |
| 8582 | if (typeof child !== 'object' || child === null) { |
| 8583 | return knownKeys; |
| 8584 | } |
| 8585 | switch (child.$$typeof) { |
| 8586 | case REACT_ELEMENT_TYPE: |
| 8587 | case REACT_PORTAL_TYPE: |
| 8588 | warnForMissingKey(child); |
| 8589 | var key = child.key; |
| 8590 | if (typeof key !== 'string') { |
| 8591 | break; |
| 8592 | } |
| 8593 | if (knownKeys === null) { |
| 8594 | knownKeys = new Set(); |
| 8595 | knownKeys.add(key); |
| 8596 | break; |
| 8597 | } |
| 8598 | if (!knownKeys.has(key)) { |
| 8599 | knownKeys.add(key); |
| 8600 | break; |
| 8601 | } |
| 8602 | 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()); |
| 8603 | break; |
| 8604 | default: |
| 8605 | break; |
| 8606 | } |
| 8607 | } |
| 8608 | return knownKeys; |
| 8609 | } |
| 8610 | |
| 8611 | function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) { |
| 8612 | // This algorithm can't optimize by searching from boths ends since we |
no test coverage detected