gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 932 forks source link

How re-render works? #671

Open rodriigovieira opened 5 years ago

rodriigovieira commented 5 years ago

Hey! This is more of a question rather than a bug/suggestion.

If I change a single item of the entire table, and then run a setTableData(data), will it re-render the entire table or just the parts that have actually changed?

Is there some kind of key property or key verification during the render process? Or should I specify something like a keyExtractor manually?

For some context: I am developing an application that uses websocket and setting the table to re-render every time data arrives from the server.

Thank you so much for this amazing library!

Tech Version
Material-UI 4.0.1
MUI-datatables 2.3.0
React 16.8.6
Chrome 74
gabrielliwerant commented 5 years ago

Hello, thank you very much for your interest!

This is a list of the primary internal state values that are being updated by setTableData as of 2.3.0:

columns,
filterData,
filterList,
searchText,
selectedRows,
data,
displayData

Some of these represent derived state, and some are a reflection of props. Unfortunately, this is the source of a number of bugs at the moment, as the library is having difficulty handling both prop updates and state updates that are derived from those props. So basically, this part of the application is very much in flux. There is a PR open here https://github.com/gregnb/mui-datatables/pull/650 that attempts to fix some issues, but causes other regressions due to these issues. You can also read my more detailed thoughts there, and I will keep that thread updated as I work through it.