diff --git a/ReactCommon/fabric/components/view/ConcreteViewShadowNode.h b/ReactCommon/fabric/components/view/ConcreteViewShadowNode.h index f9618b77130..06d1d1818e4 100644 --- a/ReactCommon/fabric/components/view/ConcreteViewShadowNode.h +++ b/ReactCommon/fabric/components/view/ConcreteViewShadowNode.h @@ -62,7 +62,7 @@ class ConcreteViewShadowNode : public ConcreteShadowNode< YogaLayoutableShadowNode::setProps( *std::static_pointer_cast(fragment.props)); YogaLayoutableShadowNode::setChildren( - BaseShadowNode::template getChildrenSlice()); + YogaLayoutableShadowNode::getYogaLayoutableChildren()); } ConcreteViewShadowNode( @@ -76,8 +76,7 @@ class ConcreteViewShadowNode : public ConcreteShadowNode< if (fragment.children) { YogaLayoutableShadowNode::setChildren( - BaseShadowNode::template getChildrenSlice< - YogaLayoutableShadowNode>()); + YogaLayoutableShadowNode::getYogaLayoutableChildren()); } } diff --git a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp index 75e512a1bce..aa4a3832bba 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp @@ -123,6 +123,20 @@ void YogaLayoutableShadowNode::appendChildYogaNode( childYogaNodeRawPtr, yogaNodeRawPtr->getChildren().size()); } +YogaLayoutableShadowNode::UnsharedList +YogaLayoutableShadowNode::getYogaLayoutableChildren() const { + YogaLayoutableShadowNode::UnsharedList layoutableChildren; + for (auto const &childShadowNode : getChildren()) { + auto layoutableChildShadowNode = + traitCast(childShadowNode.get()); + if (layoutableChildShadowNode) { + layoutableChildren.push_back( + const_cast(layoutableChildShadowNode)); + } + } + return layoutableChildren; +} + void YogaLayoutableShadowNode::setChildren( YogaLayoutableShadowNode::UnsharedList children) { if (getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)) { diff --git a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.h b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.h index f75c56c4850..f199455b801 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.h +++ b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.h @@ -90,6 +90,8 @@ class YogaLayoutableShadowNode : public LayoutableShadowNode { void layoutChildren(LayoutContext layoutContext) override; + YogaLayoutableShadowNode::UnsharedList getYogaLayoutableChildren() const; + LayoutableShadowNode::UnsharedList getLayoutableChildNodes() const override; protected: