Using map in map to generate jsx content throws error
var exampleData = [
{ name: "Alex", age: 13, date: new Date()},
{ name: "Dominic", age: 313, date: new Date()},
{ name: "Fiona", age: 33, date: new Date()}
]
var tableContent =
<div>
{exampleData.map((element,index) => {
return(
<tr>
<th scope="row">{index}</th>
{Object.keys(element).map((key)=>{
return(
<tr scope="row">{element[key]}</tr>
)}
}
</tr>
)
})
}
</div>
React throws error : Objects are not valid as a React child. If you meant to render a collection of children, use an array instead
In that case, sure i could just dont use second map and write code manually, but i have dozens of different kind of data to show up with a lot of keys that can change any time in development. Any advice how to do it dynamicaly?
