You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using DeleteWithConfirmButton on a show or edit context should work without crashing, even when viewing records that are not in the data-provider cache.
What happened instead:
When you load the page directly and the data is not cached, you get a runtime error when the DeleteWithConfirmButton tries to access the id field on undefined.
Steps to reproduce:
Make a show page
Add a DeleteWithConfimButton
Load the page directly in a browser with a known record id in the URL (simulating a bookmark)
You get a runtime error when the DeleteWithConfirmButton tries to access id on an undefined.
Because the types are not able to indicate the return value is initially undefined when the data is not cached, it does not indicate that record could be undefined. See #9622
What you were expecting:
Using DeleteWithConfirmButton on a show or edit context should work without crashing, even when viewing records that are not in the data-provider cache.
What happened instead:
When you load the page directly and the data is not cached, you get a runtime error when the DeleteWithConfirmButton tries to access the id field on undefined.
Steps to reproduce:
DeleteWithConfimButton
Other information:
The record is loaded using
useRecordContext
on this line https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/button/DeleteWithConfirmButton.tsx#L40Because the types are not able to indicate the return value is initially undefined when the data is not cached, it does not indicate that record could be undefined. See #9622
The
id
field is dereferenced from the record on without checking if it is undefined https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/button/DeleteWithConfirmButton.tsx#L87Environment
The text was updated successfully, but these errors were encountered: