mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-21 19:11:22 +08:00
Fabric: Simplified way to specialize ComponentName in ConcreteShadowNode class template
Summary: @public Previously, all ConcreteShadowNode subclasses had to override `getComponentName()` function to specialize a name of the component. And often it was all that those subclasses do. Now, it's a template argument; and many ShadowNode classes can be created as oneliners via *just* specializing ConcreteShadowNode template. Unfortunately, C++ does not allow to use `std::string`s or string literals as template arguments, but it allows to use pointers. Moreover, those pointers must point to some linked data, hence, those values must be declared in .cpp (not .h) files. For simplicity, we put those constants in Props classes, (but this is not a strong requirement). Reviewed By: mdvacca Differential Revision: D8942826 fbshipit-source-id: 4fd517e2485eb8f8c20a51df9b3496941856d8a5
This commit is contained in:
committed by
Facebook Github Bot
parent
88293d391a
commit
67a79010ca
@@ -24,7 +24,7 @@ AttributedString BaseTextShadowNode::getAttributedString(
|
||||
|
||||
for (const auto &childNode : *childNodes) {
|
||||
// RawShadowNode
|
||||
SharedRawTextShadowNode rawTextShadowNode = std::dynamic_pointer_cast<const RawTextShadowNode>(childNode);
|
||||
auto rawTextShadowNode = std::dynamic_pointer_cast<const RawTextShadowNode>(childNode);
|
||||
if (rawTextShadowNode) {
|
||||
AttributedString::Fragment fragment;
|
||||
fragment.string = rawTextShadowNode->getProps()->text;
|
||||
@@ -34,7 +34,7 @@ AttributedString BaseTextShadowNode::getAttributedString(
|
||||
}
|
||||
|
||||
// TextShadowNode
|
||||
SharedTextShadowNode textShadowNode = std::dynamic_pointer_cast<const TextShadowNode>(childNode);
|
||||
auto textShadowNode = std::dynamic_pointer_cast<const TextShadowNode>(childNode);
|
||||
if (textShadowNode) {
|
||||
TextAttributes localTextAttributes = textAttributes;
|
||||
localTextAttributes.apply(textShadowNode->getProps()->textAttributes);
|
||||
|
||||
Reference in New Issue
Block a user