* Generate a key string that identifies a component within a set. * * @param {*} component A component that could contain a manual key. * @param {number} index Index that is used if a manual key is not provided. * @return {string}
(component, index)
| 17570 | * @return {string} |
| 17571 | */ |
| 17572 | function getComponentKey(component, index) { |
| 17573 | // Do some typechecking here since we call this blindly. We want to ensure |
| 17574 | // that we don't block potential future ES APIs. |
| 17575 | if (component && typeof component === 'object' && component.key != null) { |
| 17576 | // Explicit key |
| 17577 | return wrapUserProvidedKey(component.key); |
| 17578 | } |
| 17579 | // Implicit key determined by the index in the set |
| 17580 | return index.toString(36); |
| 17581 | } |
| 17582 | |
| 17583 | /** |
| 17584 | * Escape a component key so that it is safe to use in a reactid. |
no test coverage detected
searching dependent graphs…