On the above reproduction repo, install the dependencies and run yarn dev
Load the page in any web browser
Refresh the page so that it loads again
The expected result is that the server rendered page will output the same value for both the query and initialData passed through props (as that would imply React Query is using the initialData each time). However, on the second page load, the server rendered and client rendered value disagree on the data from React Query. It appears as though the value from React Query on the server is using an earlier version of the data object from before the lifetime of the current request.
Please include below any other applicable logs and screenshots that show your problem:
It seems as though both the server and the browser agree on what serverside props should be, which makes sense as both of those are strictly per request
However, while the browser's React Query instance correctly populates with the query data object with initialData, the React Query instance on the server (during rendering) appears to ignore initialData and falls back to an earlier version of that data before the server render, so it really does feel like it's caching it
This in itself is weird as I'm pretty sure React Query (per the above linked issue on RQ) has checks to see whether or not it's running on the server (typeof window === 'undefined') and completely disables the cache, so I don't know where this behaviour would be happening
What is the problem?
Potentially related to https://github.com/tannerlinsley/react-query/issues/70, React Query seems to be caching the value of
initialData
when server renderingWhat are detailed steps to reproduce this?
https://github.com/sam3d/blitz-query-repro
yarn dev
The expected result is that the server rendered page will output the same value for both the query and
initialData
passed through props (as that would imply React Query is using theinitialData
each time). However, on the second page load, the server rendered and client rendered value disagree on the data from React Query. It appears as though the value from React Query on the server is using an earlier version of the data object from before the lifetime of the current request.Run
blitz -v
and paste the output here:Please include below any other applicable logs and screenshots that show your problem: