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
17
votes
3 answers

Infinite loading with react-table + react-virtualized / react-window

I have the following requirements to my table: Table should have fixed header It needs to autosize: for infinite scroll to work the first fetch should get sufficient amount of data for scroll to appear at all. table body should work as infinite…
12
votes
3 answers

React-Table - How to remove the 'Toggle sortBy' tooltip from the column header?

In the latest version (7.5.x) of React-Table, when using the Material-UI Table components, is there a way to remove the 'Toggle sortBy' tooltip from the column header? Two tooltips I have a tooltip with the column header name. both tooltips appear…
Vladi Feldman
  • 872
  • 1
  • 8
  • 16
10
votes
2 answers

React useTable hook with typescript

So I have a JavaScript class with useTable. In Java script its been used like below import {useTable, useFilters,useAsyncDebounce,useSortBy,usePagination,} from "react-table"; const {getTableProps,getTableBodyProps, headerGroups,…
AMendis
  • 1,346
  • 4
  • 18
  • 34
10
votes
2 answers

How to make the row editable when clicking on an "Edit" button on a cell with react-table

I am making the interactive table using react-table on my application. My goal is to make a table that can be editable per row when clicking on a button in a table cell. I designed an EditableCell like the following. import React, {useState} from…
Liki Crus
  • 1,901
  • 5
  • 16
  • 27
10
votes
5 answers

How does one supply a custom sort function for react table 7?

The documention for useSortBy sortType properties says: sortType: String | Function(rowA: , rowB: , columnId: String, desc: Bool) Used to compare 2 rows of data and order them correctly. If a function is passed, it must be…
Tom
  • 6,325
  • 4
  • 31
  • 55
10
votes
2 answers

How to pass props to row in react-table

I've been following https://blog.logrocket.com/complete-guide-building-smart-data-table-react/. To apply custom styling depending on cell value, I'm updating the column object like so: return { Header: key, accessor: key, width: "150", …
Maikol
  • 195
  • 2
  • 2
  • 10
8
votes
2 answers

How to make react table to scrollable?

I am trying to make react table scrollable horizontally and vertically but right now it is taking all the space according to the data. I want to make this table of fixed height and scrollable in both direction. Table component: import React from…
r121
  • 2,478
  • 8
  • 25
  • 44
7
votes
1 answer

React-Table keep state of selected rows

Am trying to keep the state of selected checkboxes for a react-table v7. I have a checkbox that can select multiple rows at once and works great, the issue is the table can't maintain that state once a dialog opens up for batch actions. The…
Obare13
  • 155
  • 3
  • 8
7
votes
9 answers

Make only one row selectable at a time in React Table 7.1.0

I am trying to implement react table with just one row selectable at at time. I have gone through a lot of examples for multiple rows selection in a react table but in my case, the user can select only one row when the user clicks on the radio…
Riten
  • 2,879
  • 3
  • 24
  • 28
6
votes
1 answer

what is difference between useBlockLayout vs useAbsoluteLayout in react table?

I am using react-table. I'd like to know the difference between useBlockLayout, useAbsoluteLayout and useFlexLayout. And what case can use these hooks in?
Ultimate Fire
  • 281
  • 4
  • 8
6
votes
0 answers

Using react-table with react-window and sticky columns

I have a react-table v7 (with sticky header and footer) which renders thousands of virtualized rows using react-window. A new requirement needs the table to have sticky columns as well but I cannot have it working as react-window adds a couple of…
tnsw
  • 61
  • 2
6
votes
2 answers

How can I filter out a date between a range of date in a react-table

How can I filter table data on the basis of a range of dates? setting filter to date column here: const tableInstance = useRef(null); const filterTable = (dates) => { if (tableInstance.current) { …
6
votes
4 answers

React Table - types of property 'accessor' are incompatible

I am trying out react-table in create-react-app project (version ^7.0.25). I am using the exact example from their quick start documentation. However, I am getting a type error between the accessor and data columns. below is my code, import * as…
imran chowdhury
  • 331
  • 1
  • 5
  • 18
6
votes
1 answer

React-table date range filter

I'm trying to implement a date range filter in my React-table. When I'm changing the start or end date, it triggers the filter function, creating the min and max date but when it finishes no dates are being filtered and the input is empty from the…
Shira
  • 394
  • 1
  • 6
  • 21
6
votes
2 answers

How to deal with "Warning: validateDOMNesting(...): cannot appear as a child of

I'm using react-window to create virtual tables with react-table 7 (and material UI tables). I'm embedding FixedSizeList instead TableBody. Something like this:
Tom
  • 6,325
  • 4
  • 31
  • 55
1
2 3
15 16