Preserving prefetched staleTime and other options during hydration #2903
-
I'm trying to understand how to make prefetching work with Next.js SSR. I'm prefetching data in the Here is sandbox: https://codesandbox.io/s/stoic-dhawan-sbx41?file=/pages/index.js I'm wondering how can I make react-query keep data fresh even though it was fetched in getStaticProps. Dehydrate function seems to ignore query options. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
all options are not being dehydrated - only the queries / mutations are. What you need to do is set the staleTime on the client so that it doesn't refetch. Here's a working fork of your sandbox: https://codesandbox.io/s/confident-keller-gh0nc?file=/pages/index.js |
Beta Was this translation helpful? Give feedback.
all options are not being dehydrated - only the queries / mutations are. What you need to do is set the staleTime on the client so that it doesn't refetch. Here's a working fork of your sandbox: https://codesandbox.io/s/confident-keller-gh0nc?file=/pages/index.js