From a96b4ab5a0d59a8ac3861506589a1cc449dfe7a5 Mon Sep 17 00:00:00 2001 From: Mehdi Mulani Date: Fri, 28 Oct 2016 12:08:59 -0700 Subject: [PATCH] Warn when height/width is set in style without correct flex Reviewed By: emilsjolander, yungsters Differential Revision: D4095399 fbshipit-source-id: 6246e47a39ebbc60835bc1ce5e9fb78c6630a851 --- React/Views/RCTShadowView.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/React/Views/RCTShadowView.m b/React/Views/RCTShadowView.m index 36296f74f..5253d568e 100644 --- a/React/Views/RCTShadowView.m +++ b/React/Views/RCTShadowView.m @@ -142,6 +142,16 @@ DEFINE_PROCESS_META_PROPS(Border); } CSSNodeSetHasNewLayout(node, false); +#if RCT_DEBUG + // This works around a breaking change in css-layout where setting flexBasis needs to be set explicitly, instead of relying on flex to propagate. + // We check for it by seeing if a width/height is provided along with a flexBasis of 0 and the width/height is laid out as 0. + if ((!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(node)) && CSSNodeStyleGetFlexBasis(node) == 0) && + ((!CSSValueIsUndefined(CSSNodeStyleGetWidth(node)) && CSSNodeStyleGetWidth(node) > 0 && CSSNodeLayoutGetWidth(node) == 0) || + (!CSSValueIsUndefined(CSSNodeStyleGetHeight(node)) && CSSNodeStyleGetHeight(node) > 0 && CSSNodeLayoutGetHeight(node) == 0))) { + RCTLogError(@"View was rendered with explicitly set width/height but with a 0 flexBasis. (This might be fixed by changing flex: to flexGrow:) View: %@", self); + } +#endif + CGPoint absoluteTopLeft = { absolutePosition.x + CSSNodeLayoutGetLeft(node), absolutePosition.y + CSSNodeLayoutGetTop(node)