Yawps!
Describe the bug
Table rows aren't able to access the columns in data when they have a . in the accessor key.
To Reproduce
With columns and data described below, the values for the broken column are undefined.
const columns = [
{
Header: 'broken column',
accessor: 'first.column',
},
{
Header: 'working column',
accessor: 'first-column',
},
]
const data = [
{
'first.column': 'hello world',
'first-column': 'hello again',
},
{
'first.column': 'fizz',
'first-column': 'buzz',
},
]
...
<Table columns={columns} data={data} />
...
Expected behavior
I expect the cell to still be able to access the data even with dot in the accessor key.
Codesandbox!
Use a new react-table codesandbox to reproduce the issue.
Screenshots

Desktop (please complete the following information):
Additional context
Not sure if this is by design or a limitation of my data model or a bug.
A period in an accessor is used for accessing properties on a data object.
Your column definition
const columns = [
{
Header: 'broken column',
accessor: 'first.column',
},
{
Header: 'working column',
accessor: 'first-column',
},
]
Would work well with data like this:
const data = [
{
first: { column: "hello world" },
"first-column": "hello again"
},
{
first: { column: "fizz" },
"first-column": "buzz"
}
];
Result:

You can see it in this working codesandbox: https://codesandbox.io/s/tannerlinsleyreact-table-basic-vxlcg
Oh! I see. Thank you for the clarification!
@tannerlinsley @burtyish is there any way to disable the deep inspection and treat the accessor as a normal string?
@kderbalah idk about that. But you can get full control of the logic by supplying a function as the accessor
@burtyish thanks for the quick reply. Yea, I managed to fix it by using a custom accessor
{
Header: 'First Column',
accessor: (d) => d[key], // example key first.column
id: key
}
Thanks for the hint!
Most helpful comment
@burtyish thanks for the quick reply. Yea, I managed to fix it by using a custom accessor
Thanks for the hint!