Skip to content

onSuccess not called by useDelete/deleteOne in pessimistic mode #10733

Open
@yelworc

Description

@yelworc

[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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions