diff --git a/ReactCommon/fabric/components/root/RootProps.cpp b/ReactCommon/fabric/components/root/RootProps.cpp index 32cab81aa..d30da924e 100644 --- a/ReactCommon/fabric/components/root/RootProps.cpp +++ b/ReactCommon/fabric/components/root/RootProps.cpp @@ -26,6 +26,9 @@ static YGStyle yogaStyleFromLayoutConstraints( yogaStyle.maxDimensions[YGDimensionHeight] = yogaStyleValueFromFloat(layoutConstraints.maximumSize.height); + yogaStyle.direction = + yogaDirectionFromLayoutDirection(layoutConstraints.layoutDirection); + return yogaStyle; } diff --git a/ReactCommon/fabric/components/view/conversions.h b/ReactCommon/fabric/components/view/conversions.h index 707a4622f..0b541379e 100644 --- a/ReactCommon/fabric/components/view/conversions.h +++ b/ReactCommon/fabric/components/view/conversions.h @@ -113,6 +113,17 @@ inline LayoutMetrics layoutMetricsFromYogaNode(YGNode &yogaNode) { return layoutMetrics; } +inline YGDirection yogaDirectionFromLayoutDirection(LayoutDirection direction) { + switch (direction) { + case LayoutDirection::Undefined: + return YGDirectionInherit; + case LayoutDirection::LeftToRight: + return YGDirectionLTR; + case LayoutDirection::RightToLeft: + return YGDirectionRTL; + } +} + inline void fromDynamic(const folly::dynamic &value, YGDirection &result) { assert(value.isString()); auto stringValue = value.asString(); diff --git a/ReactCommon/fabric/core/layout/LayoutConstraints.h b/ReactCommon/fabric/core/layout/LayoutConstraints.h index f93017363..33607c300 100644 --- a/ReactCommon/fabric/core/layout/LayoutConstraints.h +++ b/ReactCommon/fabric/core/layout/LayoutConstraints.h @@ -19,7 +19,7 @@ namespace react { struct LayoutConstraints { Size minimumSize{0, 0}; Size maximumSize{kFloatUndefined, kFloatUndefined}; - LayoutDirection layoutDirection; + LayoutDirection layoutDirection{LayoutDirection::Undefined}; }; } // namespace react