react-data-table-component icon indicating copy to clipboard operation
react-data-table-component copied to clipboard

Optimizing table with cells with editable cells

Open ashgh opened this issue 6 years ago • 4 comments

I have a data table with cells that include editable components (input, drop downs).

The way I have it setup is a parent component has a state variable that represents the rows and a callback to edit the row in this state is passed down to the cell component. The entire row object is also passed into the cell component and inside the component it extracts the fields it cares about.

When this callback is invoked, the state updates and the table is updated with the new row data. The problem is that there is a significant performance hit and it takes seconds for the table to update.

I am using functional components with hooks. I am memoizing the column config and am using useCallback for the set state callback, but it still chugs.

ashgh avatar Apr 24 '20 17:04 ashgh

@ashgh Can you get reproduce this into a codesandbox? It would really help to understand the issue. Even some code would help specifically focused on a cell showing this rendering issue.

https://codesandbox.io/s/ccyuu

jbetancur avatar Apr 26 '20 21:04 jbetancur

sure, here is something close to what I am doing that let's me see the slowdown when it tries to re-render the table.

https://codesandbox.io/s/react-data-table-sandbox-rfjgm

I think this conveys the idea. In my app there are additional cells that will update a row in "movies" upon action and the table will re-render to show the changes to that row. The data I am working with has about 450 rows currently.

ashgh avatar Apr 27 '20 18:04 ashgh

There is defiantly a noticeable delay but I’m not sure how this can be further optimized either from your component or rdt. Table libs aside 450 rows is a huge strain on the browser and DOM and not a great ux. To have even 100 rows can slow things down. Have you considered pagination or infinite scrolling? There’s an issue you can search for here where someone implemented infinite scroll with rdt. Another thing to note is when you productionize your app the code in your component will run faster since react is slower in dev mode.

lll keep looking if there are further rendering enhancements I can make to rdt, but can’t promise anything.

jbetancur avatar Apr 29 '20 03:04 jbetancur

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 29 '20 03:05 stale[bot]