I am trying to apply TableRow of MUI. The array that I get from the database looks like below,
a =
[
{
id: 'aa',
name: 'JJ',
participants: 32
},
{
id: 'aabb',
name: 'JJbb',
participants: 342
},
{
id: 'bb',
name: 'cc',
participants: 332
},
]
{a[0] === undefined ? <p>No event has been found</p> : a.map((aa) => {
<StyledTableRow key={aa.name} className={classes.tableRow}>
<StyledTableCell component='th' scope='row'>
{aa.id}
</StyledTableCell>
<StyledTableCell align='right'>{aa.id}</StyledTableCell>
<StyledTableCell align='right'>{aa.participants}</StyledTableCell>
</StyledTableRow>
})
}
It does not show the list of the events in that table. If I try with MUI example, then it works.
function createData(name, calories, fat, carbs, protein) {
return { name, calories, fat, carbs, protein };
}
const rows = [
createData('Frozen yoghurt', 159, 6.0, 24, 4.0),
createData('Ice cream sandwich', 237, 9.0, 37, 4.3),
createData('Eclair', 262, 16.0, 24, 6.0),
createData('Cupcake', 305, 3.7, 67, 4.3),
createData('Gingerbread', 356, 16.0, 49, 3.9),
];
{rows.map((row) => (
<TableRow key={row.name}>
<TableCell component="th" scope="row">
asdf
</TableCell>
<TableCell align="right">{row.calories}</TableCell>
<TableCell align="right">{row.fat}</TableCell>
<TableCell align="right">{row.carbs}</TableCell>
<TableCell align="right">{row.protein}</TableCell>
</TableRow>
))}
Even if I replace {aa.name}, {aa.participants}, {aa.id} to like aaa, asdf, 234, it does not display the table. Moreover, if I check the array a, it shows the correct objects inside the .map(). What is my mistake over here?