-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useIsMutating return wrong count of mutating calls #3332
Comments
As you can see from the reproducible example https://codesandbox.io/s/great-zhukovsky-vovpcg?file=/src/useCustomMutations.js the workaround is to use the |
hmm, the callbacks don't need to reject or resolve the promise again? If the mutationFn rejects, the mutation goes to error state. Just remove the callbacks:
the returned promise from From whatI can see, if the promises returned from the onError callback reject, we will never go into error state: if if the callback for funny thing: If the mutationFn succeeds, but then the |
@TkDodo thank u i see now, i used the callbacks to perform side effects and I wanted the caller to get the error too, |
@TkDodo Although the count seems wrong to me anyway, and could lead to a never ending loading state |
@FeliceGeracitano I think I have a fix for v4, we can just go to One question is: if the mutationFn throws an error, and then the |
🎉 This issue has been resolved in version 4.0.0-alpha.17 🎉 The release is available on: Your semantic-release bot 📦🚀 |
That's a good question, i think depends on how If they are just 'hooks' to events, the original error should be the one propagated, those call back should just run side-effect probably |
yes, I also went with the initial error 👍 |
🎉 This issue has been resolved in version 4.0.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Describe the bug
useIsMutating return
wrong count
of pending mutation when a failure occurYour minimal, reproducible example
https://codesandbox.io/s/great-zhukovsky-vovpcg?file=/src/useCustomMutations.js
Steps to reproduce
1 - Have custom useMutation function with callbacks
2 - Listen for useIsMutation value
3 - check number is incorrect when useMutation fails
1 - # instead of 0
Expected behavior
useIsMutations() should return 0, when there are no mutations pending
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
react-query version
3.34
TypeScript version
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: