material-table-core / core

Datatable for React based on material-ui's table with additional features. Support us at https://opencollective.com/material-table-core
https://material-table-core.github.io
MIT License
296 stars 146 forks source link

Getting error while attempting to delete row #802

Closed gnanesh05 closed 11 months ago

gnanesh05 commented 1 year ago

Hey, I'm using material-table/core along with latest version of react and mui. I'm seeing this error whenever I try to delete a row - "Cannot read properties of undefined (reading 'id')", upon inspecting the problem arises with the data passed to delete function doesn't have the tableData which holds details about the table, eg. id of a row.

I'm attaching the codesandbox link. https://codesandbox.io/s/priceless-panna-dpfyj9?file=/src/App.js

P.S. I don't see this behavior with version 4.3.45

Please help if possible.

Thanks!

Domino987 commented 1 year ago

I'll take a look. Thanks for the Sandbox

Domino987 commented 11 months ago

The tabledata is removed from the callback to reduce confusion. Its the actual item now. But you should just delete it from the array for your code. This example from the docs is just a way to simulate a server for example

gnanesh05 commented 11 months ago

Thanks for looking into it. tabledata was quite useful for identifying the data rather than looping through a large data ourselves. Is there any way to get the ID from the table?

Domino987 commented 11 months ago

Well you are supposed to add your own id anyway. That would solve it.