-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Datagrid] activate vertical scroll page and checkbox selection causes performances issues #8932
Comments
I can reproduce the issue, I'll look further into this. |
First observation, it seems that we're forcing an update in The above is no great, but the performance of the render update alone is a bigger issue: ~180ms to change a checkbox state is way too much. |
Thanks @romgrk ;) like you said changing the checkbox state causes a big re-render.. but I noticed that if we set a fixed height value for the datagrid, it's faster. Maybe the autoHeight props disable the datagrid virtualization ? |
And I tried to memoize the selection model but it does not change the problem |
hey @jdeca-decat It uses only one state for the whole thing. a simple state change like a
When you use the |
@yaredtsy thanks for your message. But I think it's always an issue to have a big latency when a row is selected in a datagrid with 100 lines and autoHeight props :( this component should be faster. |
@romgrk i have tested your solution, and it even works well with 1000 rows https://codesandbox.io/s/jovial-microservice-m773m7?file=/package.json |
@yaredtsy the checkbox selection works well !!! But there is a very big latency when I want to collapse the Card element above the table (but I think it's "normal", the free version of the datagrid not support more than 100 rows, and in our example the virtualization is not enable -> autoHeight prop) |
@jdeca-decat this is not Datagrid fault. It's b/c you are tracking the collapse state with react state so when the state changes its rerenders everything you must wrap the data grid component with Demo https://codesandbox.io/s/xenodochial-curie-pxugcs?file=/src/pages/home/components/datagrid.tsx |
Thanks for your response @yaredtsy ;) so what do you recommend in terms of best practices for placing component states ? Personally I have observed better performance when I group the states of my components in the same places like I do in the first codesandbox, and I use the useEffect hook to load server data so the page only re-renders all components under certain conditions (for example in the dependency of the useEffect I place the "nbrLine" state, in this way a call to the server is re-done when its value change and it cause updates across child components with the new values). I am looking for optimizations for our professional web application so if you have any tips please let me know :)) |
you can just use it the way you're using it. just make sure to use |
Okay thanks, so I will place my Datagrid into React.memo. And yes I know the react profiler extension but I need to look further into this because I have an incompatible warning. I think this extension is not available in React V18 or it needs to be updated. |
Please also note that the <DataGrid slots={{ row: CustomRow }} /> Should be transformed to: // outside the component
const slots = { row: CustomRow }
// inside the component
<DataGrid slots={slots} /> Or this transformation is also fine: <DataGrid slots={useMemo(() => ({ row: CustomRow }), [])} /> Otherwise the |
Thanks @romgrk for your work, I will apply the changes immediately ;) |
I think it's a very nice point and it is something we should suggest in our documentation too 🤔 @romgrk Did you get a chance to somehow measure the impact of this optimization in your experimentation, so that we can relate the gains in docs too? |
Yeah but our doc is filled with the inline version style, which is nicer for readability but bad for performance. I'll find a way to add that to the docs along with the scroll improvements (aka by default memoization).
Yeah, root props change implies all rows re-render, which can be from 50-100ms cost on my laptop. |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/lucid-cloud-oq39yg
Steps:
Current behavior 😯
Expected behavior 🤔
I have search a lot to optimize the datagrid and I have already include all the performances tips that recommended in Mui website for the latest version of the community datagrid, all github closed issues and stackoverflow discussions.. Please help all the people like me who are struggling to optimize this component.. Thanks !!!
Context 🔦
I NEED to keep a responsive width on the datagrid, an autoHeight and all renderCell methods
Your environment 🌎
@mui/x-data-grid ^6.2.1, react 18.2.0, typescript ^5.0.4, all browsersnpx @mui/envinfo
The text was updated successfully, but these errors were encountered: