question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accessor keys don't work with Dots

See original GitHub issue

Using v7?

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

Screen Shot 2019-11-29 at 3 25 09 PM

Desktop (please complete the following information):

  • OS: iOS
  • Browser: chrome
  • Version: 79.0.3945.36 (Official Build) beta (64-bit)

Additional context

Not sure if this is by design or a limitation of my data model or a bug.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

20reactions
kderbalahcommented, Jan 15, 2020

@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!

5reactions
burtyishcommented, Jan 15, 2020

@kderbalah idk about that. But you can get full control of the logic by supplying a function as the accessor

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accessor keys don't work with Dots · Issue #1671 - GitHub
Accessor keys don't work with Dots #1671 ... I expect the cell to still be able to access the data even with dot...
Read more >
Accessor keys not working with space in react-table
Table rows are not able to access the columns in response payload when they have a space in the accessor key. The column...
Read more >
Property accessors - JavaScript - MDN Web Docs - Mozilla
Property accessors provide access to an object's properties by using the dot notation or the bracket notation.
Read more >
Dot & Comma Keys not working - Apple Community
For some reason the Dot & Comma keys on my MacBook Air (13-inch, Mid 2011) running on High Sierra (10.13.6 (17G11023)) stopped working....
Read more >
Black Dot and Numbers filled up in the password box and the ...
This time there's no black dots issue! But some keys like A, Ctrl+Z, right side Ctrl not working! Sometimes the touchpad doesn't work...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found