Table rows are not able to access the columns in response payload when they have a space in the accessor key. The column displays -
on UI.
const data =[
{
"agent": {
"first name": "hello",
"lastname": "world"
}
},
"agent": {
{
"first name": "hello",
"lastname": "world"
}
}
];
const columns = [
{
Header: "First Name",
accessor: "agent['first name']"
},
{
Header: "Last Name",
accessor: "agent.lastname"
},
];
...
<Table columns={columns} data={data} />
...
have you tried creating a function instead of a string accessor?
something like
{
Header: "Last Name",
accessor: (agent) => agent.lastname
},
You have to de something like this.
{
header: "First Name",
accessor: (data) => data.agent['first name']
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.