Clone node with state in yogaNodeCloneCallbackConnector

Summary: Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23317682

fbshipit-source-id: c273804efbe48143dcecd7c62c4edced0a746bc6
This commit is contained in:
Samuel Susla
2020-08-25 14:48:38 -07:00
committed by Facebook GitHub Bot
parent 206ea36253
commit 19cd630f04
3 changed files with 8 additions and 2 deletions
@@ -445,7 +445,9 @@ YGNode *YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector(
auto oldNode =
static_cast<YogaLayoutableShadowNode *>(oldYogaNode->getContext());
auto clonedNode = oldNode->clone({});
auto clonedNode = oldNode->clone({ShadowNodeFragment::propsPlaceholder(),
ShadowNodeFragment::childrenPlaceholder(),
oldNode->getState()});
parentNode->replaceChild(*oldNode, clonedNode, childIndex);
return &static_cast<YogaLayoutableShadowNode &>(*clonedNode).yogaNode_;
}
@@ -134,7 +134,6 @@ class ConcreteShadowNode : public BaseShadowNodeT {
Sealable::ensureUnsealed();
state_ = std::make_shared<ConcreteState const>(
std::make_shared<ConcreteStateData const>(std::move(data)), *state_);
BaseShadowNodeT::getFamily().setMostRecentState(state_);
}
};
@@ -28,6 +28,11 @@ TEST(ConcreteShadowNodeTest, testSetStateData) {
shadowNode->setStateData({{10, 11}, {{21, 22}, {301, 302}}});
EXPECT_NE(
shadowNode->getState(), shadowNode->getFamily().getMostRecentState());
shadowNode->setMounted(true);
EXPECT_EQ(
shadowNode->getState(), shadowNode->getFamily().getMostRecentState());