Skip to content

Allow staleTime to be part of store (de)hydration #8936

Answered by TkDodo
jeroenpg asked this question in Ideas
Discussion options

You must be logged in to vote

I don't understand why staleTime can be provided to queryClient.fetchQuery then since it's not an observer.

it’s an extra option on fetchQuery to indicate that you only want to execute a fetch when data is older than the passed staleTime. In that sense, fetchQuery might not trigger the queryFn (ironic, I know) but it can just return cached data.

Basically want I wanted to achieve is have a fetch query in the loader that is only triggered max once per 5 minutes

That’s what staleTime of 5 minutes on fetchQuery should achieve ...

the result is hydrated on the client with my defaultStaleTime (=5000 ms for me)

again, staleTime doesn’t matter until data gets observed, so this shouldn’t ma…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@jeroenpg
Comment options

@TkDodo
Comment options

@jeroenpg
Comment options

@TkDodo
Comment options

Answer selected by jeroenpg
@jeroenpg
Comment options

@TkDodo
Comment options

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