React-table: flatColumns is undefined. Use columns instead?

Created on 18 Sep 2019  Â·  7Comments  Â·  Source: tannerlinsley/react-table

Using v7

Version: 7.0.0-alpha.22

Describe the bug
when using flatColumns to access the length of the columns (using this in conjunction with useExpanded), I get undefined.

To Reproduce
Steps to reproduce the behavior:

Given the following example:

const {
    flatColumns,
    getTableProps,
    headerGroups,
  } = useTable(
    {
      columns,
      data,
    },
    useExpanded,
  );

Getting flatColumns undefined error. Using columns property instead.

Expected behavior
Expected to have flatColumns property.

Desktop (please complete the following information):

  • MacOS Mojave 10.14
  • Version 0.68.132 Chromium: 76.0.3809.132 (Official Build) (64-bit)

Most helpful comment

This is more just a lack of docs around plugins. I’ll start making those when I find time.
On Feb 22, 2020, 8:48 AM -0700, Hunter Barrington notifications@github.com, wrote:

A little further investigation I found this: https://github.com/tannerlinsley/react-table/blob/master/docs/api/useTable.md#instance-properties
It's still unclear which property one should use and why... e.g. if I want to add a column through a hook it seems I can use allColumns, columns, and visibleColumns based on experimentation...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

All 7 comments

Try to use latest i.e. beta version

Will try it out, thanks ;)

flatColumns is new to the latest versions. You should be fine after updating

I'm seeing this issue again using 7.0.0-rc.16

Has there been a regression or change @tannerlinsley ?

It looks like according to https://github.com/tannerlinsley/react-table/blob/facb216f5ca7ed5cf2d438df1c319eac27fd70d3/CHANGELOG.md#700-rc16 that flatColumns has been renamed to allColumns

Changing my hook to reflect that seems to have resolved the issue.

@tannerlinsley it's probably worth updating examples?

e.g. https://github.com/tannerlinsley/react-table/blob/facb216f5ca7ed5cf2d438df1c319eac27fd70d3/examples/kitchen-sink/src/App.js#L320 seems to suggest we should use visibleColumns ... are there docs to reflect how each property is used?

A little further investigation I found this: https://github.com/tannerlinsley/react-table/blob/master/docs/api/useTable.md#instance-properties

It's still unclear which property one should use and why... e.g. if I want to add a column through a hook it seems I can use allColumns, columns, and visibleColumns based on experimentation...

This is more just a lack of docs around plugins. I’ll start making those when I find time.
On Feb 22, 2020, 8:48 AM -0700, Hunter Barrington notifications@github.com, wrote:

A little further investigation I found this: https://github.com/tannerlinsley/react-table/blob/master/docs/api/useTable.md#instance-properties
It's still unclear which property one should use and why... e.g. if I want to add a column through a hook it seems I can use allColumns, columns, and visibleColumns based on experimentation...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

krishna-shenll picture krishna-shenll  Â·  3Comments

panfiva picture panfiva  Â·  3Comments

tremby picture tremby  Â·  3Comments

monarajhans picture monarajhans  Â·  3Comments

mlajszczak picture mlajszczak  Â·  3Comments