diff --git a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp index 25baf6871f..5cd3b412e2 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp @@ -54,6 +54,10 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode( yogaNode_(&initializeYogaConfig(yogaConfig_)) { yogaNode_.setContext(this); + // Newly created node must be `dirty` just becasue it is new. + // This is not a default for `YGNode`. + yogaNode_.setDirty(true); + updateYogaProps(); updateYogaChildren(); } @@ -140,8 +144,6 @@ void YogaLayoutableShadowNode::appendChildYogaNode( return; } - yogaNode_.setDirty(true); - auto yogaNodeRawPtr = &yogaNode_; auto childYogaNodeRawPtr = &child.yogaNode_; auto childNodePtr = const_cast(&child); @@ -180,6 +182,10 @@ void YogaLayoutableShadowNode::updateYogaChildren() { yogaNode_.setChildren({}); + // We might undo this later at the end of the method if we can infer that + // dirting is not necessary here. + yogaNode_.setDirty(true); + auto i = int{0}; for (auto const &child : children) { auto yogaLayoutableChild = @@ -321,8 +327,9 @@ YogaLayoutableShadowNode &YogaLayoutableShadowNode::cloneAndReplaceChild( int suggestedIndex) { auto clonedChildShadowNode = child.clone({}); replaceChild(child, clonedChildShadowNode, suggestedIndex); - - return static_cast(*clonedChildShadowNode); + auto &node = static_cast(*clonedChildShadowNode); + node.yogaNode_.setDirty(true); + return node; } #pragma mark - Yoga Connectors