Skip to content
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] "Cannot read property 'id' of undefined" when rows update #575

Closed
2 tasks done
peppermint-juli opened this issue Nov 12, 2020 · 10 comments · Fixed by #599
Closed
2 tasks done

[DataGrid] "Cannot read property 'id' of undefined" when rows update #575

peppermint-juli opened this issue Nov 12, 2020 · 10 comments · Fixed by #599
Assignees
Labels
bug 🐛 Something doesn't work priority: important This change can make a difference

Comments

@peppermint-juli
Copy link

I submitted a ticket to zendesk first and was asked to create an issue here. I was also told this is similar to issue #571

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

I'm working with XGrid and since the Filter feature is not yet available, I'm trying to implement it manually, but I keep getting this error (see screenshot and screen recording bellow) and can't figure out what I'm doing wrong. Essentially what I do is re render all the rows (like in the docs https://material-ui.com/components/data-grid/rows/#the-rows-prop).

Screen Shot 2020-11-12 at 3 25 07 PM

Hnet com-image

Expected Behavior 🤔

Updating rows and/or columns should work as expected without error.

Steps to Reproduce 🕹

Tried to reproduce but it's kind of hard to reproduce all the condition since all of the data is brought from a backend, but this CodeSandbox link is more or less how I manage the data.

Steps:

  1. The rows array get 're calculated' causing the re render. The rows are fewer than before (trying to actually implement Filtering feature manually)
  2. Error occurs

Context 🔦

Basically implement Filtering feature manually.

Your Environment 🌎

Tech Version
Material-UI X v4.0.0-alpha.8
React ^16.13.1
Browser Chrome
TypeScript yes
@peppermint-juli peppermint-juli added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 12, 2020
@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work components: XGrid and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 12, 2020
@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 12, 2020

I can't reproduce the exception on the codesandbox. We could wait for the resolution of #571 to see if it solves your case but without a reproduction, we operate in the dark. You are depending on chance for the outcome.

@orhels
Copy link

orhels commented Nov 14, 2020

Been having the same issue. When updating the DataGrid from the backend with new or updated rows we get the Cannot read property 'id' of undefined error.
Updated the sandbox @PeppermintNDaisies supplied to reproduce the error: https://codesandbox.io/s/sharp-hawking-20q80. Just press the "Reproduce bug"-button two times and the grid crashes.

@peppermint-juli
Copy link
Author

@orhels Thank you so much ✨ ! I hope with this reproduction the problem can be looked into and fixed

@BrentFarese
Copy link

I submitted #571. Just FYI for everyone here, I bumped down a version to 4.0.0-alpha.8 and I am not experiencing the issue anymore. Still have more testing to do, but at least that might narrow down the issue/bug to a specific release @oliviertassinari. Thanks!

@oliviertassinari oliviertassinari added the priority: important This change can make a difference label Nov 16, 2020
@matandro
Copy link

I submitted #571. Just FYI for everyone here, I bumped down a version to 4.0.0-alpha.8 and I am not experiencing the issue anymore. Still have more testing to do, but at least that might narrow down the issue/bug to a specific release @oliviertassinari. Thanks!

Had the same issue and downgraded to alpha8 and my filter now works.

@dtassone dtassone self-assigned this Nov 17, 2020
dtassone added a commit to dtassone/material-ui-x that referenced this issue Nov 17, 2020
dtassone added a commit that referenced this issue Nov 18, 2020
* Fix #575 reset sortedRows state on prop change

* fix typescript issue

* fix lint

* prettier

* update dep array

* polish tests

* Update packages/storybook/src/stories/grid-sorting.stories.tsx

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* Update packages/storybook/src/stories/grid-sorting.stories.tsx

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* avoids confusion, sort is not immutable

* cleanup story

* refactor applySorting

* fix lint

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
@SvenFaerber
Copy link

While updating the sortedRows should fix the problem for this specific issue, I believe a related issue (which brought me here) exists for the selectedRows, which are not updated when rows change either.

@oliviertassinari
Copy link
Member

The fix can be tried with:

"@material-ui/data-grid": "https://pkg.csb.dev/mui-org/material-ui-x/commit/02423225/@material-ui/data-grid",
"@material-ui/x-grid": "https://pkg.csb.dev/mui-org/material-ui-x/commit/02423225/@material-ui/x-grid",

@oliviertassinari
Copy link
Member

So far, we have got one valid reproduction from @orhels: https://codesandbox.io/s/sharp-hawking-20q80. which is solved: https://codesandbox.io/s/nice-frog-togvz?file=/package.json.

@SvenFaerber You would need to provide a new reproduction in a new issue.

@orhels
Copy link

orhels commented Nov 19, 2020

@oliviertassinari testet it in my project and it worked flawlessly. Thanks to you and @dtassone for the hard work 👏🏼

@arhirani
Copy link

I faced the same issue, got resolved by deprecating the version to 4.0.0-alpha.8. This thread helped a lot. Thanks everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work priority: important This change can make a difference
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants