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
1
vote
0 answers

How to sort only one column at a time using react-table?

This is the table I have right now. The problem is that when I want to sort for example the column "Driver" all other columns get sorted as well. I want to be able to sort them one at a time and only when clicked. import './Table.css' import {…
1
vote
1 answer

Transform JavaScript array of object in long format for React-table

How to convert a wide-format array of objects into a long format Input Array: [ { series: "opening_balance", "Oct 2021": 12713238.3, "Nov 2021": 27713238.3, "Dec 2021": 22713238.3, }, { series: "inflow", "Oct 2021": 7, …
Rahulkg007
  • 67
  • 1
  • 8
1
vote
1 answer

How to update/manage data for react-table - useRowState plugin behaviour is unclear

I am using react-table (https://react-table.tanstack.com/) to build a table-like component. Amongst various types of columns few of them are intractable. That means based on the interaction the data(provided to the Table) must be updated. As an…
Dip686
  • 641
  • 6
  • 16
1
vote
1 answer

How to create a column of cells that only contain icons using React Table library?

Is it possible to render icons inside column cells without having any other corresponding data that's coming from the source the table's pulling from for the other table values? I'm just trying to make a column of right-facing arrows at the end of…
Roger Cooper
  • 178
  • 2
  • 19
1
vote
1 answer

How can I bold text in all cells in one specific column when using React Table library?

How would I go about bolding the text in all of the cells in one specific column in a table? In general, how would I style the cells of a specific column in a table. By the way, I'm using v7 of the React Table library.
Roger Cooper
  • 178
  • 2
  • 19
1
vote
2 answers

React-table in Material UI Dialog causes "Error: Maximum update depth exceeded. " when selecting a row and exporting it via useMountedLayoutEffect

i am getting an Error, when selecting a row in my react-table. The problem is (probably) caused by an infinite rerendering loop. The process is as follows: I want to select a row. The react-table uses the useMountedLayoutEffect() Method to notice…
1
vote
0 answers

React table column not displaying data

I am using React Table and I am trying to make my table clickable to link to a page different for reach row. but now that i have no error screen my column isn't displaying any data for any of the rows. (when i take away the Cell: (props) => …
1
vote
0 answers

React-table library- 'useTable' is not exported by node_modules/react-table/index.js

React version: 16.8.6 React-table version: 7.6.3 Hey. I am getting the next error only when trying to build my project. When running it locally, everything works fine and the hook is being imported, but when trying to build it, I am getting:…
1
vote
1 answer

How do I get the Id when clicked on the first row in React JS?

I am pretty new to React and I was following a tutorial to build a react-table, but I wanted to go one step further and see if I can make the first row or cell clickable and get the ID of that cell. However, I am unable to achieve that. I am not…
Beel
  • 23
  • 1
  • 3
1
vote
1 answer

TS2339: Property 'Cell' does not exist on type from @type/react-table in typescript

I use the @type/react-table to set up the column for my table and I have error on my IDE complain that Cell is not under correct type. I assume it is caused by Cell is optional type from @type/react-table how can I solve this? //column.tsx import…
1
vote
0 answers

default Column defined outside the Table Component, breaks the code

If defined outside default Column is not being called (Cell & Filter functions are undefined) & I get this error Error: Renderer Error ☝️ , Code for reference, export const defaultColumn = { // Set our editable cell renderer as the default Cell…
1
vote
0 answers

useState() losing the state(data) on refresh when the data is coming from redux store

I am having a weird issue that makes the data set to undefined. I am implementing react-table (one with hooks). If I use one from the example of react-table, they make use makedata.js & their code is below const [data, setData] = useState(useMemo(()…
1
vote
0 answers

React-table v7, add edit row button

I am making an interactive react-table. My goal is to make a table that can be an editable per row when clicking on a button in a table cell. I have designed an EditableCell like the following: import React, {useState} from "react"; export const…
1
vote
1 answer

Adding an HTML input control to a header in React-Table

I am using React and React-Table version 7. It is working well for me, but I want to add a checkbox to my top-level header. So I tried it like this: const columns = React.useMemo( () => [ { Header: 'Monster Types
SkyeBoniwell
  • 6,345
  • 12
  • 81
  • 185
1
vote
1 answer

Passing a GraphQL Array through React-Table

Hopefully this isn't too much of an overly basic question (though I think it might be). I've spent a few days trying to figure this out with no luck, I'm new at this. I'm trying to use GraphQL with Shopify to generate a react-table with a bunch of…