Skip to content

should useSuspenseQuery support initialData #6143

Closed Answered by TkDodo
kalijonn asked this question in Q&A
Discussion options

You must be logged in to vote

I'm trying to understand if initialData is the same as placeholderData in the context of suspense

initialData is put into the cache, placeholderData is not.

I've tried setting staleTime to 0 in the same example and it does resolve to count: 0. but when we change the count, it falls back to count: 26 before resolving to count: 1.

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:

initialData: () => queryKey === theKeyIWant ? theInitialDataIWant : undefined

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@kalijonn
Comment options

@TkDodo
Comment options

Answer selected by kalijonn
@kalijonn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants