Replies: 2 comments 2 replies
-
not sure, I don't really see where this would be happening. Can you reproduce this in codesandbox? On another note - why don't you just call |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi 👋 What does |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
Probably it's not a bug but the way it was designed, but could anyone at least update the docs to warn people of this behavior?
Here is the issue I've got into, spent time debugging it. So updating the docs will help others.
What this code does:
The code looks alright, but there is a bug. A data race kind of bug, that breaks from time to time.
Because most of the time 2 happens before 3, but sometimes 3 happens earlier than 2.
While debugging, I found out that react-query is re-rendering the component BEFORE calling
onSuccess
, and this is a big surprise because why would it do so?The callback can be called synchronously right after the loading function resolved the value, so I was expecting that react-query does exactly this, because otherwise it doesn't make sense to me. And leads to such unexpected bugs and happy debugging time with a code that looks alright.
Instead, re-render happens first, and
onSuccess
fires after some delay. Soreact-query
seems to be working in such order:Is my assumption right? Should I create an issue for this, or maybe missing something?
Beta Was this translation helpful? Give feedback.
All reactions