I have some JSON that I am looping over in my React app. Within the JSON I am looping over I have an object which contains multiple images. I would like to loop through these images and render each of them as well. Here is what I tried:
const locations = [
{
"name": "First Location",
"photos": [
{
"url": "http://placehold.it/250x250",
}, {
"url": "http://placehold.it/250x250",
}
]
}, {
"name": "Second Location",
"photos": [
{
"url": "http://placehold.it/250x250",
}, {
"url": "http://placehold.it/250x250",
}
]
}
]
const element = (
<div className="community-list">
{locations && locations.map((location, index) => (
<div key={index} className="location">
<h2>{location.name}</h2>
{Object.keys(location.photos).map(function(key) {
return <img src="{location.photos[url]}" />;
})}
</div>
))}
</div>
);
ReactDOM.render(element, document.getElementById('mountNode'));
However this gives me 2 broken images