Replies: 2 comments 2 replies
-
Thanks for sharing this, I also got hit by it but with |
Beta Was this translation helpful? Give feedback.
2 replies
-
For mutations, this is mentioned explicitly in the docs because the callbacks on https://tanstack.com/query/v4/docs/guides/mutations#mutation-side-effects |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
If a component attaches onSuccess via the mutate call on the mutation object returned by useMutation() and the component gets unmounted, for example because the dialog triggering the mutate call is unmounted, onSuccess is not called.
This is understandable but I wish there was a warning in the documentation on this point, I haven't seen anything on this point.
For example here : https://react-query.tanstack.com/guides/updates-from-mutation-responses
Would you be open to a PR ?
Here, the modal is closed before the importing process is finished, on purpose.
To remedy the situation, I used
open={false}
on the MUI dialog, to hide it instead of unmounting, but it was a bit difficult to know whyonSuccess
was not called.Edit: Actually it's been twice today that I am bitten by this bug. Either I am missing something or could it possibly be a feature request to be able to force lifecycle callbacks to be called even if components that used the mutation was unmounted ?
Beta Was this translation helpful? Give feedback.
All reactions