Skip to content

Commit 0faafdb

Browse files
authoredOct 2, 2023
Update usage-without-react-hooks.mdx
1 parent b3d66a0 commit 0faafdb

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed
 

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ 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 subscription = dispatch(api.endpoints.getPosts.initiate())
27-
// The subscription contains the same methods as you would find in the hook
28-
// ...subscription.refetch();
29-
// ...subscription.isLoading;
26+
// interact with the cache in the same way as you would with a useFetch...() hook
27+
const {data, refetch, isLoading, isSuccess, /*...*/} = dispatch(api.endpoints.getPosts.initiate())
3028
```
3129

3230
## Removing a subscription

0 commit comments

Comments
 (0)
Please sign in to comment.