-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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] Add getRowId prop #972
Conversation
packages/grid/_modules_/grid/hooks/features/rows/useGetRowId.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to update the api pages to mention the existence of the prop, otherwise, developers won't find it.
packages/grid/_modules_/grid/hooks/features/rows/useGetRowId.ts
Outdated
Show resolved
Hide resolved
consider renaming |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the updated code architecture of the PR 👍 but there is a performance regression, at least seems to be of 1 extra second with 100,000 rows. I believe it's related to the cloning behavior I have reported previously. Compare:
HEAD:
https://master--material-ui-x.netlify.app/components/data-grid/#commercial-version
PR:
https://deploy-preview-972--material-ui-x.netlify.app/components/data-grid/#commercial-version
This is the time it takes to rerender when pressing this button (the same thing with the initial render but harder to measure is isolation):
Test on this branch with spread Test on master This test was run using dev mode, react dev version, debugger open, (grid debug off)... Perf should be faster in prod |
What should we do then?
A side note on this as I don't recall making this point in the past: We shouldn't make decisions based on performance in development. It can be used as a tool to nourish intuition but has little to no value compared to what the performance in production are. |
Agree! Basically it seems that it creates a small perf hit of around 300-500ms when you parse about 100 000 rows. |
I would personally vote for going down the edge cases direction (no clone when possible). We can easily revert. So far, we only have a small number of entry points for feeding rows and the difference can be felt when opening HEAD vs. PR (look at the time the "No rows message" is shown, it goes from a few 100 ms to over a second). I also like the idea that we keep the same reference of the row, which can be important for developers to perform referential comparisons. Maybe it's also a signal that having an intermediary row data structure can help (remove the need to clone) @DanailH what do you think? |
We could remove having a |
Yeah, if we were to change the structure of the state, it might even be better to store the id into a structure close to: interface Row {
id?: string | number; // extracted id
rowData?: any; // input, referential equal with object provided by the developer.
} |
We had that before, but we won't really need it as mentioned above we can just use the key of the lookup... |
@dtassone True, I believe we have found a new use case for such structure: getRowId, and how it allows to not clone/mutate the data provided by the developer, reducing pressure on the memory and allowing developers to compare the reference (a pain I have seen popup a bunch of time in the main library, for instance, the combo box) |
I agree with the idea of maintaining the same ref. But I'm not sure about re-adding the row structure as I don't like the idea of storing meta row data in this row model as it was before as it removes the composability of the component. |
@dtassone Agree, to consider for later |
fix #378