[data grid] Component rendering 3 times on row selection, and every cell also re-rendering #16473
Labels
bug 🐛
Something doesn't work
component: data grid
This is the name of the generic UI component, not the React module!
status: waiting for author
Issue with insufficient information
Steps to reproduce
Version: "@mui/base": "^5.0.0-beta.30"
Steps:
Current behavior
I am using React Profiler and I noticed that the component DataGrid renders 3 times after clicking on a checkbox from the default checkbox selection component. Frist time it renders because the selection model changed , and then it rerenders 2 additional times ( the reason from the ReactProfiler is that the state of the internal DataGrid changed).
When there aren't many rows it's not noticeable, but when there are a lot of columns and rows, the selection is very laggy.
This is the first re-render triggered by the selection model change;
![Image](https://private-user-images.githubusercontent.com/108430938/410053021-8afb14de-b77d-4559-b4dc-dad12ccfac07.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4ODEyMjQsIm5iZiI6MTczODg4MDkyNCwicGF0aCI6Ii8xMDg0MzA5MzgvNDEwMDUzMDIxLThhZmIxNGRlLWI3N2QtNDU1OS1iNGRjLWRhZDEyY2NmYWMwNy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwNlQyMjI4NDRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03NTY4ZTI2ZWUzNzg0NTJmODBkNDkyYTFmOTYzZGVmYWFhYTc4NGM5MjViZWIyMjFmMWYyMDZhZmE2ZjRkYzE2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.76KifM2yMivXxYF7g2ENABfv4EdUifjpFTLgzZ0IvT8)
These are the 2nd and 3rd re-renders, trigger by Hook 24, which I checked and is the Grid's state ( which includes the selection model)
![Image](https://private-user-images.githubusercontent.com/108430938/410053192-859ee01c-dd9f-4209-992a-bd93368aa2a3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4ODEyMjQsIm5iZiI6MTczODg4MDkyNCwicGF0aCI6Ii8xMDg0MzA5MzgvNDEwMDUzMTkyLTg1OWVlMDFjLWRkOWYtNDIwOS05OTJhLWJkOTMzNjhhYTJhMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwNlQyMjI4NDRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05OTc1ZGUzNzkyNmIwMDgyNDhmNDdjOWNmODQ3NTljNDdlOTFjNjhjODBkNjNhMTIxMWU2MGQxM2U0NTU4NDUxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.g21ElPGTX8ffwR0JPTmMxNflPRaBpJvZ7_jnaA4UxHY)
Expected behavior
I don't know if I am missing something, but I would expect only the checkbox selection column to re-render when clicking on a checkbox, and certainly only once. Could the 3 re-renders be necessary? But why the other cells?
Context
No response
Your environment
npx @mui/envinfo
Search keywords: Mui Data Grid DataGrid render rerender row selection
The text was updated successfully, but these errors were encountered: