* Warns if there is a duplicate or missing key
(child, knownKeys)
| 9217 | * Warns if there is a duplicate or missing key |
| 9218 | */ |
| 9219 | function warnOnInvalidKey(child, knownKeys) { |
| 9220 | { |
| 9221 | if (typeof child !== 'object' || child === null) { |
| 9222 | return knownKeys; |
| 9223 | } |
| 9224 | switch (child.$$typeof) { |
| 9225 | case REACT_ELEMENT_TYPE: |
| 9226 | case REACT_PORTAL_TYPE: |
| 9227 | warnForMissingKey(child); |
| 9228 | var key = child.key; |
| 9229 | if (typeof key !== 'string') { |
| 9230 | break; |
| 9231 | } |
| 9232 | if (knownKeys === null) { |
| 9233 | knownKeys = new Set(); |
| 9234 | knownKeys.add(key); |
| 9235 | break; |
| 9236 | } |
| 9237 | if (!knownKeys.has(key)) { |
| 9238 | knownKeys.add(key); |
| 9239 | break; |
| 9240 | } |
| 9241 | 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()); |
| 9242 | break; |
| 9243 | default: |
| 9244 | break; |
| 9245 | } |
| 9246 | } |
| 9247 | return knownKeys; |
| 9248 | } |
| 9249 | |
| 9250 | function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) { |
| 9251 | // This algorithm can't optimize by searching from boths ends since we |
no test coverage detected