Skip to content

Commit b3d66a0

Browse files
authored
Update usage-without-react-hooks.mdx
Add examples of what you can do with the subscription in the first subscribe code example
1 parent 52ab548 commit b3d66a0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +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-
dispatch(api.endpoints.getPosts.initiate())
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;
2730
```
2831

2932
## Removing a subscription

0 commit comments

Comments
 (0)