diff --git a/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp b/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp index b6220fe53..5ebcf8c0e 100644 --- a/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp +++ b/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp @@ -38,21 +38,23 @@ bool LayoutableShadowNode::LayoutableShadowNode::isLayoutOnly() const { LayoutMetrics LayoutableShadowNode::getRelativeLayoutMetrics( const LayoutableShadowNode &ancestorLayoutableShadowNode) const { - std::vector> ancestors; - auto &ancestorShadowNode = dynamic_cast(ancestorLayoutableShadowNode); auto &shadowNode = dynamic_cast(*this); - if (!shadowNode.constructAncestorPath(ancestorShadowNode, ancestors)) { + auto ancestors = shadowNode.getAncestors(ancestorShadowNode); + + if (ancestors.size() == 0) { return EmptyLayoutMetrics; } auto layoutMetrics = getLayoutMetrics(); - for (const auto ¤tShadowNode : ancestors) { + for (auto it = ancestors.rbegin(); it != ancestors.rend(); ++it) { + auto ¤tShadowNode = it->first.get(); + auto layoutableCurrentShadowNode = - dynamic_cast(¤tShadowNode.get()); + dynamic_cast(¤tShadowNode); if (!layoutableCurrentShadowNode) { return EmptyLayoutMetrics;