I'm new to React and frontend development. My objective is to let <img src={child.s3_url} className={classes.magetty} />
to work successfully in the map()
, and I hope there are many pictures on the page. However, images do not show correctly on the page (only blank space in the view), and I use console.log('child.s3_url: ', child.s3_url)
to make sure that the map() has already been fired. Could anyone tell me what is the solution to this problem? Thank you very much!
My code is here:
<Grid className={classes.gridList}>
{comments.comments_images.map((child,i) =>{
<div key={i}>
<img src={child.s3_url} className={classes.magetty} />
</div>
//console.log('=====s3_url=====', child.s3_url);
})}
</Grid>
Data looks like this:
"comments": [
{
"id": 4,
"trail_id": 4,
"date": "2009-02-05",
"star": 4,
"difficulty": 3,
"comments_images": [
{
"comment_id": 1,
"tag_id": 1,
"s3_url": "https://justForTestUrl/imgs/1.jpg"
},
{
"comment_id": 2,
"tag_id": 2,
"s3_url": "https://justForTestUrl/imgs/2.jpg"
},
{
"comment_id": 3,
"tag_id": 3,
"s3_url": "https://justForTestUrl/imgs/3.jpg"
},
]
},
...
],