The problem
flex: 0 sizes elements down to their intrinsic size (as is correct and expected), keeping them at width: 8 and height: 8.flex: 0 sizes elements down all the way to 0px on the main axis (i.e. "width" for a child of a row), causing them to disappear from view.
|
|
|
| iOS | Android | Web |
How to reproduce
I've reproduced the same minimum-working example for both RNW alone and for Expo (to show native behaviour).
Steps to reproduce:
flex: 0 style to an element, along with explicit width and height.Expected behavior
For both flex: 0 and flex: -1, my PageIndicator should look like this (disregarding the background colour), respecting the width: 8 and height: 8 properties of the indicator circles:

Sizing should be consistent between iOS/Android and Web, and should adhere to the React Native documentation's stated behaviour for flex:
In React Native
flexdoes not work the same way that it does in CSS.flexis anumberrather than astring, and it works according to the Yoga.When
flexis a positive number, it makes the component flexible, and it will be sized proportional to its flex value. So a component withflexset to 2 will take twice the space as a component withflexset to 1.flex: <positive number>equates toflexGrow: <positive number>, flexShrink: 1, flexBasis: 0.When
flexis 0, the component is sized according towidthandheight, and it is inflexible.When
flexis -1, the component is normally sized according towidthandheight. However, if there's not enough space, the component will shrink to itsminWidthandminHeight.
flexGrow,flexShrink, andflexBasiswork the same as in CSS.
Environment (include versions). Did this work in previous versions?
flex: 0 has behaved poorly for as long as I have used RNW.
v37.0.00.11.716.12.0Additional context
See:
I don't know if this can be done on web. React Native doesn't correctly implement the W3C spec and we've had discussions about fixing that so there is cross platform consistency
This might be caused by the flexBasis 0% default
This should be fixed in the @canary version
Most helpful comment
This should be fixed in the
@canaryversion