Questions tagged [react-table-v7]

Hooks for building fast and extendable tables and datagrids for React. v7 was a major refactor of the library, eliminating the component for a headless hook-based data organization utility. For questions about the component and other deprecated methods from previous versions, use [react-table-v6]. For questions about the most recent version of react-table or the TanStack Table useReactTable hook, use [react-table].

The most recent version of react-table is the @tanstack/react-table adapter of the TanStack Table libary. This tag is specifically for questions about v7, which was a major refactor over previous versions, and differs in other ways from v8 and beyond.

Website

https://react-table-v7.tanstack.com/

Demos

https://react-table-v7.tanstack.com/docs/examples/basic

Docs

https://react-table-v7.tanstack.com/docs/overview

Example

const {
  getTableProps,
  getTableBodyProps,
  headerGroups,
  rows,
  prepareRow,
} = useTable({
  columns,
  data,
})

// Render the UI for your table
return (
  <table {...getTableProps()}>
    <thead>
      {headerGroups.map(headerGroup => (
        <tr {...headerGroup.getHeaderGroupProps()}>
          {headerGroup.headers.map(column => (
            <th {...column.getHeaderProps()}>{column.render('Header')}</th>
          ))}
        </tr>
      ))}
    </thead>
    <tbody {...getTableBodyProps()}>
      {rows.map((row, i) => {
        prepareRow(row)
        return (
          <tr {...row.getRowProps()}>
            {row.cells.map(cell => {
              return <td {...cell.getCellProps()}>{cell.render('Cell')}</td>
            })}
          </tr>
        )
      })}
    </tbody>
  </table>
)
227 questions
5
votes
2 answers

How to initially auto-expand all rows with react-table 7?

I'm looking for an easy and clean way to make all rows to be auto-expanded when using react-table v7. When I map all the data to true and set it as an initial state, it does not expand my rows. const expanded = { 1: true, 2: true, …
simPod
  • 11,498
  • 17
  • 86
  • 139
5
votes
1 answer

How to access to another column's value from a column in v7 (React-Table)

I see in previous versions that you can access it using : const columns = [ { Header: "Name", accessor: "name", Cell: (e) => { return e.original.name; } } ]; But in v7 it doesn't work.
antoninislam
  • 117
  • 1
  • 2
  • 9
5
votes
1 answer

Create nested table using react-table v7

thanks for your help in advance. The problem that I am trying to solve is to create a table with react-table v7 and within that table using the expand and display another table with data related to the first selection as it is attached in the…
5
votes
1 answer

react-table 7 custom cell says data undefined

In version 6 this used to work, some of the rows doesn't have price, but original should be pointing to the row. { accessor : 'price', Header: () => Price, style: { 'whiteSpace': 'unset' }, …
James Lin
  • 25,028
  • 36
  • 133
  • 233
5
votes
1 answer

React Table using hooks expand and collapse rows

I am using react-table component inside my project. The row expansion property is something that my features utilized and it is working fine now. I need the ability to collapse all the rows while I expand a row. ie Only one row should be open at a…
Vivek V Nair
  • 199
  • 1
  • 3
  • 12
4
votes
1 answer

TypeError: Cannot read properties of undefined (reading 'filter') Tanstack table (React)

I have a tanstack table in NextJS and it works perfectly in dev. However, in prod, it gives a client-side exception: framework-3b5a00d5d7e8d93b.js:9 TypeError: Cannot read properties of undefined (reading 'filter') at…
Joel Hager
  • 2,990
  • 3
  • 15
  • 44
4
votes
2 answers

react-table CellProps issue with on TypeScript

On react-table v7, I have a table where each row is a nested object. When using TypeScript, For the properties that are not directly on the base row object, I have some issues getting the column definition array to work properly. As seen in the…
Knut Marius
  • 1,588
  • 18
  • 40
4
votes
4 answers

How to use useMemo with an external API?

I'm working with react-table library for filtering and pagination. I am requesting data from a custom API using Node and rendering it using useTable hook from react-table. The documentation for react-table says the table data should be memoized, so…
4
votes
3 answers

Why is my react Table not updating the data?

I got a react Table that I want to delete or modify my data. My code is below for all my cells. deleteTableElement = (row) => { let data = this.state.list.data; data.splice(row.id, 1); this.setState({ list:{ …
4
votes
2 answers

React table is getting sorted on filter

I am creating a grid for my project where I need to implement column filtering. I have done it mostly, but facing an issue, that is whenever I click on the filter input box for ID column that column gets sorted. I have tried using…
Polly Banerjee
  • 197
  • 1
  • 10
4
votes
0 answers

How to re-render only one cell?

I am using react-table v7 and I'm running into an issue where when I change one cell's data, the entire table re-renders. I have thousands of rows, so re-rendering every time is pretty slow. My react-table calls a form that the user can fill out to…
Anonymous
  • 239
  • 4
  • 16
4
votes
1 answer

How to manage noDataComponent or display no rows found in ReactTable V7

I was using the older version of React Table for last couple of months and now when i started using Latest version v7, i started facing difficulty in customizing the table while no data is found in the table to be displayed. It doesn't show any…
4
votes
1 answer

react-table - How to fix width of th elements

I using react-table and I want to use table-layout: fixed. I would like to specify the width of the columns using classNames. Is there any way react-table allows to set a fix width for some columns ? If not, How could I add classNames to …
kitimenpolku
  • 2,604
  • 4
  • 36
  • 51
4
votes
3 answers

Why does my react table say that columns are undefined?

I'm trying to use react-table and it's throwing an error. It displays the following stack trace to the screen when I run it: It seems to be trying to create a map from the columns but throwing an error because columns is undefined. I am passing it…
gib65
  • 1,709
  • 3
  • 24
  • 58
3
votes
1 answer

React: declaration merging for react-table types doesn't work. Property doesn't exist on type 'TableInstance'

I'm facing an odd issue while implementing pagination for my react-table component. The problem is what you can see in the screenshot - Property X does not exist on type 'TableInstance: So I found a similar problem that someone had before and I…
D.Zet
  • 753
  • 3
  • 11
  • 32
1
2
3
15 16