Hydration for queries that don't have an observer #6064
Replies: 2 comments 1 reply
-
Not sure where exactly this is happening, but it shouldn't refetch during hydration. All it should do is put the queries into the cache... Yes, they have no |
Beta Was this translation helpful? Give feedback.
-
Oh you're right we do call |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I use a
PersistQueryClientProvider
in my app. When the app starts, my queries are hydrated. During hydration react-query tries to refetch them. The issue I have is that for some queries there is no observer attached and so they don't have any queryFn available. If auseQuery
is called directly then there is an observer and it works fine but for queries that I call in deeper parts of my application the fetch fails and the state of the query is then in error state. This led to a bug somewhere in our app because we checked theisError
boolean and displayed an error state if it was true. I wanted to know if this was the expected behavior and what would be the recommended way for dealing with that? For now we have updated our logic to display the error state only when there is an error and the data is not defined but I'm not sure it's the best solution. What bothers me the most is that it's a very easy mistake to make and it took us a while to figure out what was happening. What's your recommendation?Beta Was this translation helpful? Give feedback.
All reactions