We have the following state in react:
state = {
thumbnail: [],
title: [],
}
Which gets set after we retrieve some data from themoviedb api, like
axios.get(
`http://api.themoviedb.org/3/discover/movie?sort_by=popularity.desc&with_genres=28,99&api_key=${apiKey}`
)
.then(res => {
const thumbnail = res.data.results.map(res => res.poster_path)
const title = res.data.results.map(res => res.original_title)
this.setState({ thumbnail, title })
// console.log(posterPath);
})
So our state will look like :
thumbnail: ['url1', 'url2'] // 20 entries
title: ['title1', 'title2'] // 20 entries, too
Then I want to render a list which has to take these two props as values and Display them, but I don't know how to, what I've tried is:
{Object.entries(this.state).map((url,i) => {
console.log(url[1]);
return(
<ImageCard
key={i}
source={{uri: 'http://image.tmdb.org/t/p/w342'+url.thumbnail}}
style={{width: width * 0.3, height: height * 0.3, margin: 3}}
title={url.title}
/>
);
})}
But it doesn't work, i wanna map over the whole state object So i won't have to do two maps, anyone has any ideea how can I map over this data structure?