question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Data ID in react-table to prevent full re-rendering

See original GitHub issue

What version of React-Table are you using?

Your bug may already be fixed in the latest release. Run yarn upgrade react-table! 6.5.3

What bug are you experiencing, or what feature are you proposing?

This is a feature proposal to conditionally render rows only if their ID have changed (thus introducing the concept of a row level ID)

The scenario we are trying address is the following:

  • the data prop is derived from an external state (say managed by redux and wired in through a HOC)
  • one of the Column allows the user to edit a cell in-place, and on input submission dispatches an action that updates the redux store
  • when the redux store is updated, the react-table instance will receive a new data prop and the entire table re-renders as expected

This introduces some performance issues:

  1. the entire table is re-rendered even though a single cell in a single row was updated

If for each element in data, we provided an accessor for a row key could we use that as a hint to bypass calling render on that row?

In other words, when a row key is provided - cell level accessor(s) are no longer being invoked. It is no longer react-table’s responsibility to detect cell level changes and force re-renders. It is now the custom Cell’s responsibility to re-render itself

In this scenario - with row keys enabled, react-table is only responsible for laying out rows based on key … i.e. to the extent that rows (identified by their keys) are re-arranged, inserted or removed from data

You can imagine this feature being very helpful for data intensive projects where cell values are a complex function of both the row key, column ID + the entire App’s state (i.e. redux + mobx store)

Use https://codesandbox.io/s/X6npLXPRW (by clicking the “Fork” button) to reproduce the issue.

Then paste a link to your newly forked codesandbox here…

What are the steps to reproduce the issue?

  1. list the steps
  2. to reproduce
  3. the issue

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
gary-menzelcommented, Oct 16, 2017

@shaun-k9 Despite the feature request being considered, react-table is actually not designed for rendering thousands of rows. All of the design statements and the code itself is based around a paged table (not around rendering all of the data).

Obviously, though, any PR to implement it would be seriously considered.

1reaction
tannerlinsleycommented, Aug 23, 2019

In v7, you are able to render rows with any key prop that you choose (this will override the automatic internal key provided in row.getRowProps()

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data ID in react-table to prevent full re-rendering #520 - GitHub
when the redux store is updated, the react-table instance will receive a new data prop and the entire table re-renders as expected. This ......
Read more >
Reducing React table rerendering - Stack Overflow
The problem I'm running into is that whenever a single row is edited, each row is re-rendered. For larger tables this causes noticeable ......
Read more >
How to stop re-rendering lists in React? - Alex Sidorenko
Components always re-render ... First, let's simplify our example by removing all props from the Item . We will still update the parent...
Read more >
React re-renders guide: everything, all at once - Developer way
Comprehensive guide on React re-renders. The guide explains what are re-renders, what is necessary and unnecessary re-render, ...
Read more >
How to useMemo to improve the performance of a React table
I profiled the table with the Profiler in React Devtools and found that all the rows were re-rendering even though only one of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found