Different staleTime for data from HydrationBoundary #9974
Unanswered
LightScrool
asked this question in
Ideas
Replies: 1 comment
-
|
You can set
|
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!
First of all, thank you for this beautiful library:)
About the problem
Data in my application updates quite often and it is important to provide fresh data
That is why i need to have
staleTime = 0But i have SSR in the application, and to prevent refetching immediately on the CSR, the documentation recommends to increase staleTime
So i have to either increase staleTime to avoid refetching immediately but that could worsen UX, or keep staleTime equals to zero, but there will be extra requests
I tried to fix it by setting
staleTime=10*1000on initializing QueryClient and then inuseEffect(so after rehydration) changing it to zero (by queryClient.setDefaultOptions).But changed staleTime is applying only to new queries. The ones that was called during rehydration continue to work with
staleTime=10*1000.It's seems to me like there should be different solution to the immediate refetch on CSR, than changing the staleTime.
Beta Was this translation helpful? Give feedback.
All reactions