Skip to content

Commit 0c50ba5

Browse files
sherginfacebook-github-bot
authored andcommitted
Fabric: Moving logic from ConcreteViewShadowNode constructors to YogaLayoutableShadowNode constructors
Summary: Now we can move custom to `YogaLayoutableShadowNode` code from `ConcreteViewShadowNode<>` template to `YogaLayoutableShadowNode` itself reducing the amount of templated code and reduce overall complexity. Note, here we have to do `dynamic_cast` for now, we will address that in coming diffs. Changelog: [Internal] Fabric-specific internal change. Reviewed By: mdvacca Differential Revision: D20052021 fbshipit-source-id: dac5969a97b75e54c7728a1ca8161922bd2245ca
1 parent 6f08c37 commit 0c50ba5

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

ReactCommon/fabric/components/view/ConcreteViewShadowNode.h

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,7 @@ class ConcreteViewShadowNode : public ConcreteShadowNode<
5454
Ts...>;
5555
using ConcreteViewProps = ViewPropsT;
5656

57-
ConcreteViewShadowNode(
58-
ShadowNodeFragment const &fragment,
59-
ShadowNodeFamily::Shared const &family,
60-
ShadowNodeTraits traits)
61-
: BaseShadowNode(fragment, family, traits) {
62-
YogaLayoutableShadowNode::setProps(
63-
*std::static_pointer_cast<const ConcreteViewProps>(fragment.props));
64-
YogaLayoutableShadowNode::setChildren(
65-
YogaLayoutableShadowNode::getYogaLayoutableChildren());
66-
}
67-
68-
ConcreteViewShadowNode(
69-
ShadowNode const &sourceShadowNode,
70-
ShadowNodeFragment const &fragment)
71-
: BaseShadowNode(sourceShadowNode, fragment) {
72-
if (fragment.props) {
73-
YogaLayoutableShadowNode::setProps(
74-
*std::static_pointer_cast<const ConcreteViewProps>(fragment.props));
75-
}
76-
77-
if (fragment.children) {
78-
YogaLayoutableShadowNode::setChildren(
79-
YogaLayoutableShadowNode::getYogaLayoutableChildren());
80-
}
81-
}
57+
using BaseShadowNode::BaseShadowNode;
8258

8359
static ShadowNodeTraits BaseTraits() {
8460
auto traits = BaseShadowNode::BaseTraits();

ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode(
2929
yogaConfig_(nullptr),
3030
yogaNode_(&initializeYogaConfig(yogaConfig_)) {
3131
yogaNode_.setContext(this);
32+
33+
setProps(dynamic_cast<YogaStylableProps const &>(*fragment.props));
34+
setChildren(YogaLayoutableShadowNode::getYogaLayoutableChildren());
3235
}
3336

3437
YogaLayoutableShadowNode::YogaLayoutableShadowNode(
@@ -47,6 +50,14 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode(
4750
assert(
4851
static_cast<YogaLayoutableShadowNode const &>(sourceShadowNode)
4952
.yogaNode_.isDirty() == yogaNode_.isDirty());
53+
54+
if (fragment.props) {
55+
setProps(dynamic_cast<YogaStylableProps const &>(*fragment.props));
56+
}
57+
58+
if (fragment.children) {
59+
setChildren(YogaLayoutableShadowNode::getYogaLayoutableChildren());
60+
}
5061
}
5162

5263
void YogaLayoutableShadowNode::cleanLayout() {
@@ -165,7 +176,7 @@ void YogaLayoutableShadowNode::setChildren(
165176
yogaNode_.setDirty(!isClean);
166177
}
167178

168-
void YogaLayoutableShadowNode::setProps(const YogaStylableProps &props) {
179+
void YogaLayoutableShadowNode::setProps(YogaStylableProps const &props) {
169180
ensureUnsealed();
170181

171182
// Resetting `dirty` flag only if `yogaStyle` portion of `Props` was changed.

0 commit comments

Comments
 (0)