Dependent query returns undefined when refetching #415
-
Hey @tannerlinsley, I think I might have found a bug related to dependent queries and refetching ( Example to reproduce it: const { data: token } = useQuery(['token', userId], getToken)
const { data: user } = useQuery(token ? ['user', token] : false, getUser)
console.log({ token, user })
... When refetching I expect to get the previous —current— data but instead Two things I've noticed:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Dependent Queries are always in a "success" state upon initialization, so long as a falsy query key is used. Only when the query key becomes truthy does a dependent query start the |
Beta Was this translation helpful? Give feedback.
-
The punctuate, this is intended behavior. |
Beta Was this translation helpful? Give feedback.
-
@tannerlinsley thanks for answering! In this case, when refreshing, the query key of the dependent query is valid (truthy) and it returns |
Beta Was this translation helpful? Give feedback.
-
Hmmm. I think you'll need to make a codesandbox to better explain what's happening. |
Beta Was this translation helpful? Give feedback.
Hmmm. I think you'll need to make a codesandbox to better explain what's happening.