I am attempting to map an array of objects (photo details) into a component so that it will line them up in rows with three (3) components in each row (three images).
I have tried creating a nested for loop to have the components print out like I described but to no avail. I am fairly new to React Native, but have been programming in other languages (C, Java, Javascript) for years.
Here is my code thus far:
class PhotoList extends Component {
render() {
var payments = [];
for(let j = 0; j < PHOTO_DATA.length; J++){
payments.push(
<View>
)
for(let i = 0; i < 3 || j < PHOTO_DATA.length; i++){
j = j + 1;
payments.push(
<Photo key={i} {...PHOTO_DATA.pop} press={this.props.press} />
)
}
payments.push(
</View>
)
}
return (
<View style={photoList.container}>
<ScrollView>
{ payments }
{/* {PHOTO_DATA.map((item, i) => {
return <Photo key={i} {...item} press={this.props.press} />
})} */}
</ScrollView>
</View>
)
}
}
Any help is very much appreciated, thanks!