-
Describe the bug
Your minimal, reproducible exampleno way I could provide one with SSR set up Steps to reproduce
useQuery(['yo'], () => Promise.resolve([123]), { cacheTime: 1230000 });
queryClient.prefetchQuery(['yo'], () => 'data', { cacheTime: 2340000 }),
Note, the actual value is not This will NOT happen if you remove the SSR code from your app. Expected behaviorLogically I'd expect the Then, in order of precedence, should go the value set at the component level. If none of the above provided, the default one should get used instead (300 seconds). How often does this bug happen?Every time Screenshots or VideosNo response Platform
react-query version3.34.8 TypeScript version4.5.4 Additional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
we have a next-js ssr example in the docs? to answer the question: we only dehydrate the state of the query, not it's options: what I would do is to set the defaults in the |
Beta Was this translation helpful? Give feedback.
we have a next-js ssr example in the docs?
to answer the question: we only dehydrate the state of the query, not it's options:
https://github.com/tannerlinsley/react-query/blob/19861272f57da5e587bce5bff449d0c3020243e0/src/core/hydration.ts#L60-L66
what I would do is to set the defaults in the
QueryClient
, or viasetQueryDefaults
, or directly on the useQuery on the client rather than on the server.