In my react native app I'm trying to simulate grid view and center it, but currently I can't achieve it without moving last row to the center (which is incomplete). It should be aligned to the left like first row.
export const GridComponent = () => {
return (
<View style={styles.container} bg="amber.100">
<Box style={styles.item} width={150} height={150} bg="blue.100" />
<Box style={styles.item} width={150} height={150} bg="blue.100" />
<Box style={styles.item} width={150} height={150} bg="blue.100" />
</View>
);
};
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'center',
background: 'red',
},
item: {
margin: 10,
},
});
.
Added marginRight: 'auto'
to the item class isn't solution because then whole grid isn't centered:
.