Skip to content

Commit

Permalink
Update usage-without-react-hooks.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
Azeirah authored Oct 2, 2023
1 parent b3d66a0 commit 0faafdb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions docs/rtk-query/usage/usage-without-react-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ Cache subscriptions are used to tell RTK Query that it needs to fetch data for a
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).

```ts title="Subscribing to cached data" no-transpile
const subscription = dispatch(api.endpoints.getPosts.initiate())
// The subscription contains the same methods as you would find in the hook
// ...subscription.refetch();
// ...subscription.isLoading;
// interact with the cache in the same way as you would with a useFetch...() hook
const {data, refetch, isLoading, isSuccess, /*...*/} = dispatch(api.endpoints.getPosts.initiate())
```

## Removing a subscription
Expand Down

0 comments on commit 0faafdb

Please sign in to comment.