marmelab / marmelab/react-admin
onSuccess not called by useDelete/deleteOne in pessimistic mode
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 26.9k
- Forks
- 5.5k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 19
Description
[This is a v4 bug, which I hope is still supported, since it's mentioned in the issue template? I did not have time to check if the issue exists in v5 as well.]
What you were expecting:
I'm using the deleteOne function returned by useDelete with the (default) pessimistic mutation mode, and onSuccess and onError callbacks supplied in the options object. One of these callbacks should be invoked after the delete request responds, corresponding to the response code.
What happened instead:
When the DELETE request fails, onError is invoked as expected. When the request succeeds though, onSuccess is not called. It is only called when I change the mutation mode to optimistic.
Steps to reproduce:
Repro: https://stackblitz.com/edit/github-718bhh69?file=src%2Fposts%2FPostList.tsx
Check the post list view; the delete button labeled "ERROR" will fail, logging "ERROR!" in the console. The button labeled "SUCCESS" however will not log "SUCCESS!", even though it does delete the post.
Environment
- React-admin version: 4.16.20
- Last version that did not exhibit the issue (if applicable): did not try v5
- Browser: Vivaldi 7.3.3635.11
- Stack trace (in case of a JS error): n/a
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the StackBlitz reproduction at src/posts/PostList.tsx and trace useDelete/deleteOne in pessimistic mode. Verify the SUCCESS and ERROR buttons against React-admin 4.16.20; done means a successful DELETE invokes onSuccess and a failed request still invokes onError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100