-
-
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
[data grid] Grid crashes when switching from tree data to regular grid #15826
Comments
Hey @Zitrooone thanks for reporting this. Regarding the Codesandbox, it is a known issue and we have opened an issue upstream. More info here #15765 |
Is there a specific reason you are processing the rows the way you are in your example? I found that this is the cause of the error *I am also using the version of the grid that is not released yet but has the codesandbox issue resolved |
Hi @arminmeh, thanks for the heads up regarding the Codesandbox. And thank you for your example. The reason we process the rows this way is that we have multiple groupings you could chose, which would dictate the way the hierarchy is built up. Essentially more cases in the I was playing around with your suggestion, but kept stumbling across bits that make the current use of Any idea what causes the error in the first place? |
I tinkered with the example and made this, hoping it helps and does not cause more confusion. I will try to explain: I hope this made sense. If not, I apologise! I will look into this topic further tomorrow with a fresh head. PS: Knowing the cause of the error might help me figure out what to avoid, if it is indeed a fault in my architecture. I was considering it being some sort of out-of-sync data due to the useMemo, but I cannot make sense of it unfortunately. |
Thanks for all the info and additional example @Zitrooone This is what I have observed last time
I have to investigate why the mismatch happens. If it is on our side I can fix that, but you should still be aware that this setup re-renders grid multiple times. Once I get more details I will get back to you. |
Thanks for the feedback @arminmeh Looking at the code I would think that |
Hi @Zitrooone I have found the root cause of the error and found a way for your last example to work with the current data grid. If you look at first warnings in Row definition and Column definition pages you can see that it is not expected to deal with rows and columns in the way you did. But I think that the grid should still handle your case, only with the mentioned performance degradation. Error is caused by the way the updates are being processed when both This is why I have updated the sandbox to keep the rows reference stable (when Let me know if something else (not included in your last example) is blocking you to keep the reference stable. |
Hi @arminmeh Thank you for your update. I don't quite understand why the Unfortunately my time to test is very limited, as I'm leaving for vacation very soon. I can do a deep dive and implement this fix in our various grids early next year. Let me know if you need anything from me. |
You can ignore this, I should have cleaned it up.
Issue only happens if |
Note for the team The error happens because when both Problem is, for So, in this cycle it tries to build tree data lookups, but without any rows which crashes the grid. Fixing this problem will also get rid of this extra cycle which will help performance. |
Another workaround for this issue is to change the |
Steps to reproduce
Steps:
Cannot read properties of undefined (reading 'depth')
Current behavior
The grid crashes when I "turn off" the treeData view.
Expected behavior
The grid does not crash and treeData is turned off, which results in a regular grid being displayed.
Context
This was working just fine with V6 of the DataGrid. I recently wanted to migrate to V7 and started encountering this issue. Before I crafted the example I encountered another error, which was
Could not find row with ID #0
. I can no longer replicate it though.I tried to build an example that is as close as possible to what we are using. For some reason codesandbox has issues previewing the example
Rendered fewer hooks than expected. This may be caused by an accidental early return statement.
. Is this a problem with my setup or with codesandbox?Your environment
npx @mui/envinfo
Search keywords: treeData
Order ID: 102617
The text was updated successfully, but these errors were encountered: