Mutation stuck at loading
Hi there! I've searched and found this issue that seems related: https://discord.com/channels/719702312431386674/1081312089282461826
Basically I'm calling a mutation from an effect but its status remains
loading
. However, if I add the onSettled callback, data
is defined so I don't understand what's wrong.
Here is a simplified version of my code, thanks in advance for the help!
5 Replies
xenogeneic-maroon•3y ago
react 18, strict mode
there's a recent issue / discussion somewhere on github
i've explained everything there. your "ref workaround" makes thing worse
stormy-goldOP•3y ago
Gonna search for it
For now I edited to this and it seems to work, but that's really hacky:
Thanks for your help!
stormy-goldOP•3y ago
Is it what you are talking about? https://github.com/TanStack/query/issues/5341
GitHub
Mutations can not be started from an effect in Reacts StrictMode · ...
Describe the bug When firing a mutation from a useEffect on component creation the mutation get's stuck in loading state, despite the underlying request finishing. This only seems to happen in ...
xenogeneic-maroon•3y ago
yep
stormy-goldOP•3y ago
great thanks