Skip to content

Commit 7d88135

Browse files
authored
docs: Update the documentation for gcTime in setQueryData (TanStack#10559)
Clarified the behavior of gcTime in setQueryData. https://bsky.app/profile/tkdodo.eu/post/3mk2z7ur7kc2m
1 parent e7de909 commit 7d88135

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

docs/reference/QueryClient.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ This distinction is more a "convenience" for ts devs that know which structure w
250250

251251
## `queryClient.setQueryData`
252252

253-
`setQueryData` is a synchronous function that can be used to immediately update a query's cached data. If the query does not exist, it will be created. **If the query is not utilized by a query hook in the default `gcTime` of 5 minutes, the query will be garbage collected**. To update multiple queries at once and match query keys partially, you need to use [`queryClient.setQueriesData`](#queryclientsetqueriesdata) instead.
253+
`setQueryData` is a synchronous function that can be used to immediately update a query's cached data. If the query does not exist, it will be created. **If the query is not utilized by a query hook within the default `gcTime`, the query will be garbage collected. If the default `gcTime` has not been configured, it defaults to 5 minutes.** To update multiple queries at once and match query keys partially, you need to use [`queryClient.setQueriesData`](#queryclientsetqueriesdata) instead.
254254

255255
> The difference between using `setQueryData` and `fetchQuery` is that `setQueryData` is sync and assumes that you already synchronously have the data available. If you need to fetch the data asynchronously, it's suggested that you either refetch the query key or use `fetchQuery` to handle the asynchronous fetch.
256256

0 commit comments

Comments
 (0)