Below I have a flexbox row. What I'm trying to achieve is this: I'd like to have a row of 5 boxes and I want to be able to set some of the boxes (not all) specific widths using flexBasis
(flex-basis
). Below I have set the first box to flexBox: 'content'
or flexBox: '150px'
(a deliberate) size.
I'm looking for a way for box 2, 3, 4, 5 to all be the same size and take up the full amount of it's parent.
let {flexContainer, flexBox, custom} = StyleSheet.create({
flexContainer: {
backgroundColor: 'green',
padding: '30px',
flexDirection: 'row',
},
flexBox: {
padding: '30px',
flexBasis: '20%',
backgroundColor: 'red',
borderColor: 'blue',
borderWidth: 1
},
custom: {
flexBasis: 'content'
}
})
class SampleApp extends Component {
render() {
return (
<View style={flexContainer}>
<View style={[flexBox, custom]}>
meow
</View>
<View style={flexBox}>
meowmeow
</View>
<View style={flexBox}>
meowmeowmeow
</View>
<View style={flexBox}>
meow
</View>
<View style={flexBox}>
meow
</View>
</View>
)
}
}
// rendering
const rootTag = document.getElementById('react-root');
AppRegistry.registerComponent('SampleApp', () => SampleApp);
AppRegistry.runApplication('SampleApp', { rootTag });