Skip to content

Commit c3ce98d

Browse files
committed
refetch is on the promise not the result
1 parent 2e6833f commit c3ce98d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/rtk-query/usage/usage-without-react-hooks.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ Cache subscriptions are used to tell RTK Query that it needs to fetch data for a
2323
With React hooks, this behavior is instead handled within [`useQuery`](../api/created-api/hooks.mdx#usequery), [`useQuerySubscription`](../api/created-api/hooks.mdx#usequerysubscription), [`useLazyQuery`](../api/created-api/hooks.mdx#uselazyquery), and [`useLazyQuerySubscription`](../api/created-api/hooks.mdx#uselazyquerysubscription).
2424

2525
```ts title="Subscribing to cached data" no-transpile
26+
const promise = dispatch(api.endpoints.getPosts.initiate())
27+
const { refetch } = promise
2628
// interact with the cache in the same way as you would with a useFetch...() hook
27-
const { data, refetch, isLoading, isSuccess /*...*/ } = await dispatch(
28-
api.endpoints.getPosts.initiate()
29-
)
29+
const { data, isLoading, isSuccess /*...*/ } = await promise
3030
```
3131

3232
## Removing a subscription

0 commit comments

Comments
 (0)