-
I'm currently testing v5 to understand suspense support better. https://codesandbox.io/p/sandbox/competent-frost-zryxvf What I thought would happen: It would return count: 26, and 500ms later would update to count: 0 I can trick it to return count:0 by clicking refetch which does a background refetch and updates the count to 0. But right after that when I click changeCount, it flips back to count: 26 and stays there. clicking refetch again, does the background refetch and updates count to 1. It looks like count:26 is being used as a loading state but never actually loads completely. Is it recommended to use initialData with useSuspenseQuery? Using initial data with useSuspenseQuery never throws a promise and hence never suspends. or I'm doing something wrong in my code. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
when you set The reason why you never see the queryFn running is because with However, |
Beta Was this translation helpful? Give feedback.
initialData is put into the cache, placeholderData is not.
if you change the queryKey, you get a new cache entry. If you set
initialData: 26
, that cache entry will get it too. If you only want initialData for a specific cache entry, you have to be specific about that: