Skip to content

Commit 4f8f1c8

Browse files
authored
docs: Add side effect from using setQueryData (TanStack#2691)
1 parent 1beedf9 commit 4f8f1c8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/src/pages/reference/QueryClient.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ This distinction is more a "convenience" for ts devs that know which structure w
205205

206206
`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 `cacheTime` of 5 minutes, the query will be garbage collected**.
207207

208+
After successful changing query's cached data via `setQueryData`, it will also trigger `onSuccess` callback from that query.
209+
208210
> 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.
209211
210212
```js

0 commit comments

Comments
 (0)