[v2] stuck on isLoading when I setQueryData for initial load #649
-
Describe the bug For my app, as the initial data was saved in local storage, I do not wish to make network call and show spinner. After upgrade to v2, I noticed that the app stuck at To Reproduce
Expected behavior Desktop (please complete the following information):
Additional context |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I think this is what you're looking to do: https://codesandbox.io/s/react-query-2-setquerydata-5765w?file=/src/index.js |
Beta Was this translation helpful? Give feedback.
-
Pretty sure the reason for this is:
https://codesandbox.io/s/react-query-2-setquerydata-9rm0m?file=/src/index.js |
Beta Was this translation helpful? Give feedback.
Pretty sure the reason for this is:
setQueryData
will not bring a query out of a loading mode.initialData
as is prescribed and designated in the docs, you are using setQueryData imperatively. The only way to usesetQueryData
and avoid the loading state is to ensure that it is done before the query for it loads.https://codesandbox.io/s/react-query-2-setquerydata-9rm0m?file=/src/index.js