Skip to content
Discussion options

You must be logged in to vote

You're just getting a refetch because staleTime is zero and you refocus the window when you go from the code editor to the iframe on the right in codesandbox, so the background refetch is interfering with your mutation. It's a classic gotcha

from https://tkdodo.eu/blog/practical-react-query#the-defaults-explained

If you see a refetch that you are not expecting, it is likely because you just focused the window and React Query is doing a refetchOnWindowFocus, which is a great feature for production: If the user goes to a different browser tab, and then comes back to your app, a background refetch will be triggered automatically, and data on the screen will be updated if something has chang…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@shichongrui
Comment options

Answer selected by shichongrui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants