React Query Caching not updating after cache time #1256
Unanswered
Karthick1911
asked this question in
Q&A
Replies: 2 comments 1 reply
-
React-query doesn’t re-fetch when you render a component. It’s well described here: https://react-query.tanstack.com/docs/guides/important-defaults cacheTime only sets the time until inactive queries (those that have no observer) are being removed from the cache. You want staleTime, but that is 0 anyways. Not sure what your use-case is exactly. Maybe you want to set a |
Beta Was this translation helpful? Give feedback.
0 replies
-
Can I know wat happens when queries are inactive, I tried setting cacheTime
to 10ms but after 10ms to I can able to get the data from cache is that the
default behavior or am I wrong
…On Fri, 6 Nov, 2020, 11:49 pm Dominik Dorfmeister, ***@***.***> wrote:
React-query doesn’t re-fetch when you render a component. It’s well
described here:
https://react-query.tanstack.com/docs/guides/important-defaults
cacheTime only sets the time until inactive queries (those that have no
observer) are being removed from the cache. You want staleTime, but that is
0 anyways.
Not sure what your use-case is exactly. Maybe you want to set a
refetchInterval to fetch periodically, i don’t know..
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1256 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGFZBZOWR24I43YAL7SUEJDSOQ42NANCNFSM4TKKTA7Q>
.
|
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.
-
Hi,
I'm new to react query, i have set the below as default config
defaultConfig: { queries: { refetchOnWindowFocus: false, }, },
and set the cacheTime to 10millisec. Even after 10 millisec if i update the component I get the same cached data even if new data is added to api by other members. Wats the actuall usage of using cacheTime.
Crct me if my understanding is wrong.
Beta Was this translation helpful? Give feedback.
All reactions