Refetch only if query is not active #6895
Unanswered
aliakbarazizi
asked this question in
Q&A
Replies: 1 comment 4 replies
-
|
staleTime is the solution :) |
Beta Was this translation helpful? Give feedback.
4 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.
Uh oh!
There was an error while loading. Please reload this page.
-
I wonder is there anyway to refetch only when the query is not active?
I already try this
refetchOnMount: (query) => !query.isActive(),But the value from
isActiveis the fresh value and its always consider active, but I want to know if the query was active before or not.For explaining why I want this
I have a query which used in many component and in some page all of them are mounting(sometime with small 1 sec delay) and because of that, its trying to refetch the query because its mounted, but since the query is active in another component I don't want to refetch,
I can put
staleTimeto 1 second but I wonder is there any more cleaner to this?in summary
I just to know to access
isActivebefore query mounted.Beta Was this translation helpful? Give feedback.
All reactions