mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 06:38:13 +00:00
Fabric: Introduced ComponentDescriptorRegistry::at() method family
Summary: This is more usable (because it allows to use `->` operator) and safe (const-style) methods replacing old `operator[]` methods. Reviewed By: mdvacca Differential Revision: D12876744 fbshipit-source-id: 8ea7398c9777f8be3e88db873ec00915d0761615
This commit is contained in:
parent
ee5061886e
commit
6c5b8c603b
@ -81,6 +81,24 @@ static const std::string componentNameByReactViewName(std::string viewName) {
|
|||||||
return viewName;
|
return viewName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ComponentDescriptor &ComponentDescriptorRegistry::at(
|
||||||
|
ComponentName componentName) const {
|
||||||
|
auto unifiedComponentName = componentNameByReactViewName(componentName);
|
||||||
|
|
||||||
|
auto it = _registryByName.find(unifiedComponentName);
|
||||||
|
if (it == _registryByName.end()) {
|
||||||
|
throw std::invalid_argument(
|
||||||
|
("Unable to find componentDescriptor for " + unifiedComponentName)
|
||||||
|
.c_str());
|
||||||
|
}
|
||||||
|
return *it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ComponentDescriptor &ComponentDescriptorRegistry::at(
|
||||||
|
ComponentHandle componentHandle) const {
|
||||||
|
return *_registryByHandle.at(componentHandle);
|
||||||
|
}
|
||||||
|
|
||||||
SharedShadowNode ComponentDescriptorRegistry::createNode(
|
SharedShadowNode ComponentDescriptorRegistry::createNode(
|
||||||
Tag tag,
|
Tag tag,
|
||||||
const std::string &viewName,
|
const std::string &viewName,
|
||||||
|
@ -25,6 +25,9 @@ class ComponentDescriptorRegistry {
|
|||||||
void registerComponentDescriptor(
|
void registerComponentDescriptor(
|
||||||
SharedComponentDescriptor componentDescriptor);
|
SharedComponentDescriptor componentDescriptor);
|
||||||
|
|
||||||
|
const ComponentDescriptor &at(ComponentName componentName) const;
|
||||||
|
const ComponentDescriptor &at(ComponentHandle componentHandle) const;
|
||||||
|
|
||||||
const SharedComponentDescriptor operator[](
|
const SharedComponentDescriptor operator[](
|
||||||
const SharedShadowNode &shadowNode) const;
|
const SharedShadowNode &shadowNode) const;
|
||||||
const SharedComponentDescriptor operator[](
|
const SharedComponentDescriptor operator[](
|
||||||
|
Loading…
x
Reference in New Issue
Block a user