diff --git a/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp b/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp index 6ad453100e8..9aadda4d83c 100644 --- a/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp @@ -97,6 +97,11 @@ void YogaLayoutableShadowNode::appendChild(SharedYogaLayoutableShadowNode child) auto nonConstYogaNode = std::const_pointer_cast(yogaNode_); auto nonConstChildYogaNode = std::const_pointer_cast(child->yogaNode_); nonConstYogaNode->insertChild(nonConstChildYogaNode.get(), nonConstYogaNode->getChildrenCount()); + + if (nonConstChildYogaNode->getParent() == nullptr) { + child->ensureUnsealed(); + nonConstChildYogaNode->setParent(nonConstYogaNode.get()); + } } void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) { @@ -211,7 +216,14 @@ void YogaLayoutableShadowNode::setYogaNodeChildrenBasedOnShadowNodeChildren(YGNo continue; } - yogaNodeChildren.push_back((YGNode *)yogaLayoutableShadowNode->yogaNode_.get()); + YGNode *yogaNodeChild = (YGNode *)yogaLayoutableShadowNode->yogaNode_.get(); + + yogaNodeChildren.push_back(yogaNodeChild); + + if (yogaNodeChild->getParent() == nullptr) { + yogaLayoutableShadowNode->ensureUnsealed(); + yogaNodeChild->setParent(&yogaNode); + } } yogaNode.setChildren(yogaNodeChildren);