I have the following data structure that I am trying to render in a table in React. However I keep getting a undefined issue getting the 'errors' nested array.
My data is the following:
const messages= [
{ invoice: "81", errors: [{ Message: "Invoice # must be unique." }] },
{ invoice: "82", errors: [{ Message: "Invoice # must be unique." },
{ Message: "No total amount." }]},
{ invoice: "85", errors: [{ Message: "Invoice # must be unique." }] }
];
My React table is the following:
<table>
<thead>
<tr>
<th>Invoice</th>
<th>Errors</th>
</tr>
</thead>
{messages.map(e => {
return (
<tbody>
<tr>
<td>{e.invoice}</td>
{messages.errors.map(e => {
return (
<td>
<ul>{e.errors}</ul>
</td>
);
})}
</tr>
</tbody>
);
})}
</table>
My table is rendered and e.invoice is displaying corrrectly, however I am getting a "cannot map errors of undefined" error.