I need to add 3 buttons per row. Since there are many device sizes I fear that my code will return different number of buttons per row. How can I sort this ?
So what ever the device width it is, the code should always return only 3 buttons per row. The width of the button should auto-shrink based on the width to accommodate 3 buttons per row.
My code, at the moment returns 3-buttons per row, but the number changes when the width of the screen changes.
...
mygetButtons = () => {
const buttons = [];
for( let i = 0; i < 9; i++) {
buttons.push(
<TouchableOpacity style={styles.but} key={i}>
<Text> Hi </Text>
</TouchableOpacity>
)
}
return buttons;
}
...
<View style={styles.frame}>
{this.mygetButtons ()}
</View>
...
frame: {
flex: 0.5,
flexDirection: 'row',
flexWrap: 'wrap',
width: window.width
},
but: {
flexDirection: 'row',
flexWrap: 'wrap',
paddingTop: 15,
paddingRight : 115,
paddingLeft: 5,
}