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

Cannot read properties of undefined (reading 'id')-Material table core #748

Closed SmackzR6 closed 1 year ago

SmackzR6 commented 1 year ago

Good day guys, Im currently having a problem where when i delete a record i get this error below Uncaught TypeError: Cannot read properties of undefined (reading 'id')

Here is the sandbox - https://codesandbox.io/s/shy-surf-6w9vud?file=/src/App.js

ErrorDelete

click delete to remove a record.

A record should be deleted. Without any errors. Debugging shows there is no tabledata index row object. same behavior on demo page https://material-table-core.com/demos/edit/editable/#usage

Desktop (please complete the following information):

Domino987 commented 1 year ago

We decided not to expose the inner workings anymore aka tabledata. So try this

setTimeout(() => {
              const dataDelete = data.filter((el) => el.id !== oldData.id);
              setData(dataDelete);
              resolve();
            }, 1000);

I also updated the docs to reflect this. ty

SmackzR6 commented 1 year ago

Thank you Domino. all is working as expected :)