Issue with migrating from v3 to v5 related to mutations
I am trying to migrate our codebase to use v5 of react query. However, this has resulted in one issue that I am not able to debug or find any relevant material for it in the docs.
Use case - We have a button, clicking on which fires a callback. Inside this we call the
mutateAsync method returned by useMutation . Once a response is returned from it, we do some computation, and then redirect to a different route on our page using history.push where history is provided using useHistory.
Issue - This was working fine in v3. However, in v5, some additional re-renders are happening. This is causing some invalid page state to come up, which ends up causing the app to crash. Earlier, when execution reached the redirection point, it would immediately redirect to that route without delay. Now, that is not happening.
What have I tried - I have two fixes for this, either using window.location.href or shifting the entire redirect logic into a useEffect . Both of these work in practice, but aren't good solutions.
I would greatly appreciate if someone could tell what is the issue here, and what can I do to fix this. Happy to provide more details3 Replies
like-gold•11mo ago
Hi
I am interested on your post.
ratty-blushOP•11mo ago
Any help on this would be greatly appreciated !!
like-gold•10mo ago
I am developer.
give me details.