React Map Returned Error Of Objects Are Not Valid As A React Child
I failed to render jxs using map of lodash. I have this in my render method return (
{map(groupedByMonths, (obj, index) =>
Solution 1:
Don't know how to do this with lodash map
, i can suggest this:
{Object.keys(groupedByMonths).map((obj, index) =><divclassName="panel"><divclassName="panel-heading">
{obj}
</div>
{groupedByMonths[obj].map((el, i) => <divkey={i}> {el.price} </div>)}
</div>)
}
When we use Object.keys(groupedByMonths)
it will return an array
that will contain all the keys, and we can use map
on that. To print the key use {obj}
and to print the values use {groupedByMonths[obj]}
.
Post a Comment for "React Map Returned Error Of Objects Are Not Valid As A React Child"