marmelab / marmelab/react-admin

onSuccess not called by useDelete/deleteOne in pessimistic mode

Open
#10,733 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs more info v4
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.