I am playing around with React-Native again, focusing on layouts this time around, and ran into an interesting problem. If I set alignItems:'center' on a parent View, the children under it don't seem to have their widths properly set.
This code will produce a single green box taking up the whole screen.
React.createClass({
render: function() {
return (
<View style={{flex: 1, alignItems: 'center',backgroundColor:'green'}}>
<View style={{flex:1, backgroundColor:'blue'}} />
<View style={{flex:1, backgroundColor:'red'}} />
</View>
);
}
});
However if I remove the alignItems style or set it to 'stretch' I get a blue box on top of a red box as I would expect
var BrownBag = React.createClass({
render: function() {
return (
<View style={{flex: 1, backgroundColor:'green'}}>
<View style={{flex:1, backgroundColor:'blue'}} />
<View style={{flex:1, backgroundColor:'red'}} />
</View>
);
}
});
What am I missing in my understanding of how alignItems works?