Replies: 2 comments 3 replies
-
It certainly does refetch when the QueryKey changes.
you need to set a
|
Beta Was this translation helpful? Give feedback.
-
I'm not fully aware of your complete code context, but based on what you've shared, this appears to be intended behavior. While it's certainly expected that a query should refetch when the query key changes, let me explain what's happening in the code When the queryKey changes, a new Query instance is created. At this point, query/packages/query-core/src/query.ts Lines 190 to 191 in f49cc75 Looking at the query/packages/query-core/src/query.ts Line 713 in f49cc75 When initialData exists, dataUpdatedAt is set to either initialDataUpdatedAt or Date.now() .
Looking back at your code, the important points are that you have To summarize your situation and the code flow Now examining the refetch logic in Looking closely at It calls query/packages/query-core/src/query.ts Line 309 in f49cc75 It returns !timeUntilStale(this.state.dataUpdatedAt, staleTime) .
And query/packages/query-core/src/utils.ts Line 97 in f49cc75 returns the time remaining until the data becomes stale. In summary, Matching this to your situation
This is my understanding of why refetch doesn't occur even when the queryKey changes. What do you think? And in my opinion, to perform the action you want, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I first get the initial data from the server and I want to display the data immediately when the page is refreshed.
The problem is that
useInfiniteQuery
does not re-fetch when the queryKey changes.I tried
placeholderData
, but the problem is that it fetches the data when the page is hydrated (this is not correct because I have the same data on the server).Beta Was this translation helpful? Give feedback.
All reactions