Skip to content

Accessor keys don't work with Dots #1671

@ajtran

Description

@ajtran

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions