Replies: 2 comments 4 replies
-
the call to invalidateQueries would refetch the current question. So if we are on question5, that would get refetched. Then, the with a staleTime of zero, it should just work as you described. I think the invalidation is pretty much unnecessary, but it also doesn't hurt. I can take a look if you can put this in a codesandbox reproduction and it also doesn't work there. |
Beta Was this translation helpful? Give feedback.
4 replies
-
Since its resolved, the conclusion for this is:
Hope it helps someone. |
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.
-
Hello everyone, I've got some trouble about invalidating or refetching query using React Query.
I have a program using React app as my front end, and Nest JS app as my back end. The feature I do here is fetch random question from server every question form is submitted.
My server is implementing caching but on testing with postman, the randomness of questions are not affected. Even tries to disable the caching seems not change anything.
To ensure the data is always new, I'm implementing useQuery and useMutation like this:
I declare the QueryClientProvider in root, and QueryClient outside the root component as per documentation.
What happened is when form is submitted, the data from useQuery doesn't change nor re-hit the api, it become severe when tries to invalidate manually from react-query-devtools the data not changes on invalidated multiple times.
I've tried staleTime to 0, turn off refetch and retry options but to no avail.
Is it a solution to this? Thank you.
Beta Was this translation helpful? Give feedback.
All reactions