Skip to content

Commit

Permalink
added docs entry for removeQueryData
Browse files Browse the repository at this point in the history
  • Loading branch information
riqts committed Feb 15, 2024
1 parent e805dc9 commit 7d6aacd
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/rtk-query/api/created-api/api-slice-utils.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,42 @@ dispatch(
patchCollection.undo()
```

### `removeQueryData`

#### Signature

```ts no-transpile
const removeQueryData = (
endpointName: string,
args: any
) => ThunkAction<void, PartialState, any, UnknownAction>;
```

- **Parameters**
- `endpointName`: a string matching an existing endpoint name
- `args`: a cache key, used to determine which cached dataset needs to be updated

#### Description

A Redux thunk that removes a specific query result from the cache. This immediately updates the Redux state with those changes.

The thunk accepts two arguments: the name of the endpoint we are updating (such as `'getPost'`) and the appropriate query arg values to construct the desired cache key.

#### Example

```ts no-transpile
const patchCollection = dispatch(
api.endpoints.getPosts.initiate(undefined),

// when cache data should be removed
dispatch(
api.util.removeQueryData(
'getPosts',
undefined,
),
)
```
### `prefetch`
#### Signature
Expand Down

0 comments on commit 7d6aacd

Please sign in to comment.