Reputation: 51
I am trying to render an objects key and value, however it just doesn't seem to work.
I have managed to display it in the console, but not the actual dom. I am iterating through the object which has multiple entries.
What do I need to do to actually print out the values?
{attributes.map(items => {
{Object.keys(items).map((key) => {
console.log(key, items[key]);
})}
})}
Upvotes: 4
Views: 18330
Reputation: 74096
Like this:
{attributes.map((items, index) => {
return (
<ul key={index}>
{Object.keys(items).map((key) => {
return (
<li key={key + index}>{key}:{items[key]}</li>
)
})}
</ul>
)
})}
Upvotes: 9