NDeveloper NDeveloper - 1 year ago 110
React JSX Question

json data to render in <TableRow> in react

I am trying to render a

of a format like:
enter image description here

in a
like :

{this.state.tableData.map((row, index) => (
<TableRow key={index}>

the console in the code snippet is giving me the correct value I can check in the browser.

enter image description here

But the code snippet

is giving the error
Error : TypeError: Cannot read property 'name' of undefined

any suggestion please!!

Answer Source

Because, you should call table data with this.state.tableData in rows too, not with tableData[index], because tableData is undefined. But I would recommend you to use row variable which you have inside the map function.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download