Permalink
Browse files

Warn when height/width is set in style without correct flex

Reviewed By: emilsjolander, yungsters

Differential Revision: D4095399

fbshipit-source-id: 6246e47a39ebbc60835bc1ce5e9fb78c6630a851
  • Loading branch information...
mmmulani authored and Facebook Github Bot committed Oct 28, 2016
1 parent 45275e3 commit a96b4ab5a0d59a8ac3861506589a1cc449dfe7a5
Showing with 10 additions and 0 deletions.
  1. +10 −0 React/Views/RCTShadowView.m
@@ -142,6 +142,16 @@ - (void)applyLayoutNode:(CSSNodeRef)node
}
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)

0 comments on commit a96b4ab

Please sign in to comment.