Skip to content

Commit 7d6aacd

Browse files
committed
added docs entry for removeQueryData
1 parent e805dc9 commit 7d6aacd

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/rtk-query/api/created-api/api-slice-utils.mdx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,42 @@ dispatch(
197197
patchCollection.undo()
198198
```
199199

200+
### `removeQueryData`
201+
202+
#### Signature
203+
204+
```ts no-transpile
205+
const removeQueryData = (
206+
endpointName: string,
207+
args: any
208+
) => ThunkAction<void, PartialState, any, UnknownAction>;
209+
```
210+
211+
- **Parameters**
212+
- `endpointName`: a string matching an existing endpoint name
213+
- `args`: a cache key, used to determine which cached dataset needs to be updated
214+
215+
#### Description
216+
217+
A Redux thunk that removes a specific query result from the cache. This immediately updates the Redux state with those changes.
218+
219+
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.
220+
221+
#### Example
222+
223+
```ts no-transpile
224+
const patchCollection = dispatch(
225+
api.endpoints.getPosts.initiate(undefined),
226+
227+
// when cache data should be removed
228+
dispatch(
229+
api.util.removeQueryData(
230+
'getPosts',
231+
undefined,
232+
),
233+
)
234+
```
235+
200236
### `prefetch`
201237
202238
#### Signature

0 commit comments

Comments
 (0)