MCPcopy Create free account
hub / github.com/Lucifier129/react-lite / getComponentKey

Function getComponentKey

examples/simple/react.js:17016–17023  ·  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

17014 * @return {string}
17015 */
17016function getComponentKey(component, index) {
17017 if (component && component.key != null) {
17018 // Explicit key
17019 return wrapUserProvidedKey(component.key);
17020 }
17021 // Implicit key determined by the index in the set
17022 return index.toString(36);
17023}
17024
17025/**
17026 * Escape a component key so that it is safe to use in a reactid.

Callers 1

traverseAllChildrenImplFunction · 0.70

Calls 1

wrapUserProvidedKeyFunction · 0.70

Tested by

no test coverage detected