I'm trying to create a table with dynamic data so that I can reuse the table. The headers are displaying as intended but the rows are not displaying at all.
Data:
[
{
"id": "1231",
"name": "Michael",
"phone": "11223311",
"medical": "YES"
},
{
"id": "32123",
"name": "Johnson",
"phone": "3311323",
"medical": "NO"
}
]
Headers:
const headCells = [
{id: 'id'},
{id: 'name'},
{id: 'phone'},
{id: 'medical'}
What I've done:
const rows = () => {
if (data) {
data.map((row) =>
<TableRow key={row.uuid}>
<TableCell>{row}</TableCell>
</TableRow>)
}
};
return(
<TableContainer component={Paper}>
<Table stickyHeader aria-label="sticky table">
<TableHead>
<TableRow>
{headers.map((headCell) => (
<TableCell>{headCell.id}</TableCell>
))}
</TableRow>
</TableHead>
<TableBody>
{rows}
</TableBody>
</Table>
</TableContainer>
)
With this the headers are displaying but the rows are not. Can anybody see why?
nullreturn value. Edit: Or rather no value at all - equals no render^^