I need to render the below object into subsequent tr/tds via JSX...
{
"0": [
{
"colIndex": 0,
"data": {
"richTextModule": "Data row 1 cell 1"
}
},
{
"colIndex": 0,
"data": {
"richTextModule": "Data row 2 cell 1"
}
}
],
"1": [
{
"colIndex": 1,
"data": {
"richTextModule": "Data row 1 cell 2"
}
},
{
"colIndex": 1,
"data": {
"richTextModule": "Data row 2 cell 2"
}
}
],
"2": [
{
"colIndex": 2,
"data": {
"richTextModule": "Data row 1 cell 3"
}
},
{
"colIndex": 2,
"data": {
"richTextModule": "Data row 2 cell 3"
}
},
{
"colIndex": 2,
"data": {
"richTextModule": "Data row 3 cell 3"
}
}
]
}
I've tried
Object.values(obj).map((column, index) => {
return column.map((row, rowIndex) => {
return obj[index][rowIndex].data.richTextModule;
});
}
Expected output should be...
<tr>
<td>Data row 1 cell 1</td>
<td>Data row 1 cell 2</td>
<td>Data row 1 cell 3</td>
</tr>
<tr>
<td>Data row 2 cell 1</td>
<td>Data row 2 cell 2</td>
<td>Data row 2 cell 3</td>
</tr>
Any ideas on how to achieve this?
Object.values().map()call.