I have following scenario where I need loop through a data set and return multiple post. Each post has a title and few images attached to it. I am able to loop through all the data, but its returning the same title multiple times instead of just once.
Desired output:
My title img 1 img 2
Current Output:
My title image1 My title image 2
JS:
const mappedFlickr = this.state.articles.map((flickr, i) => {
return (
flickr.fields.featuredImage.map((st, i) => {
return (
<div>
<span>{flickr.fields.title}</span>
<img src={st.fields.file.url +'?w=300&h=300'} />
</div>
)
})
)
})
return (
<section>
{ mappedFlickr }
</section>
)
flickr.fields.titlewill be the same title regardless what image you have in the loop. Why don't you move the<span>out of thefeaturedImage.map, right in the<section>?