MCPcopy Create free account
hub / github.com/Lobos/react-ui / getComponentKey

Function getComponentKey

docs/lib/react.js:17572–17581  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

17570 * @return {string}
17571 */
17572function 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.

Callers 1

traverseAllChildrenImplFunction · 0.85

Calls 1

wrapUserProvidedKeyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…