I'm following this tutorial and got stuck with the dynamic TouchableOpacity elements. For some reason, the flex property is not being applied. When I view the elements using chrome's dev tools I can see them but they don't have a flex property. If I add it manually, I get the look I want.
Here is the render snippet:
render() {
const { rgb, size } = this.state;
const { width } = Dimensions.get('window');
return (
<View style={styles.container}>
<Header fontSize={40} />
<View
style={{
height: width * 0.875,
width: width * 0.8758,
flexDirection: 'row',
}}
>
{Array(size)
.fill()
.map((val, columnIndex) => (
<View
style={{ flex: 2, flexDirection: 'column' }}
key={columnIndex}
>
{Array(size)
.fill()
.map((val, rowIndex) => (
<TouchableOpacity
key={`${rowIndex}.${columnIndex}`}
style={{
flex: 1,
backgroundColor: `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`,
margin: 2,
}}
onPress={() =>
console.log(
rowIndex,
columnIndex
)
}
/>
))}
</View>
))}
</View>
</View>
);
}