Skip to content

Commit 2de3d84

Browse files
committed
📝 Update/extend 'reset mutation' documentation
1 parent 9e36af6 commit 2de3d84

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

docs/rtk-query/api/created-api/hooks.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ type UseMutationTrigger<T> = (arg: any) => Promise<
323323
requestId: string // A string generated by RTK Query
324324
abort: () => void // A method to cancel the mutation promise
325325
unwrap: () => Promise<T> // A method to unwrap the mutation call and provide the raw response/error
326-
unsubscribe: () => void // A method to manually unsubscribe from the mutation call
326+
reset: () => void // A method to manually unsubscribe from the mutation call and reset the result to the uninitialized state
327327
}
328328

329329
type UseMutationResult<T> = {
@@ -340,6 +340,8 @@ type UseMutationResult<T> = {
340340
isSuccess: boolean // Mutation has data from a successful call
341341
isError: boolean // Mutation is currently in an "error" state
342342
startedTimeStamp?: number // Timestamp for when the latest mutation was initiated
343+
344+
reset: () => void // A method to manually unsubscribe from the mutation call and reset the result to the uninitialized state
343345
}
344346
```
345347

docs/rtk-query/usage/error-handling.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ import { toast } from 'your-cool-library'
9494
export const rtkQueryErrorLogger: Middleware = (api: MiddlewareAPI) => (
9595
next
9696
) => (action) => {
97-
// RTK Query uses `createAsyncThunk` from redux-toolkit under the hood, so we're able to utilize these use matchers!
97+
// RTK Query uses `createAsyncThunk` from redux-toolkit under the hood, so we're able to utilize these matchers!
9898
if (isRejectedWithValue(action)) {
9999
console.warn('We got a rejected action!')
100100
toast.warn({ title: 'Async error!', message: action.error.data.message })

docs/rtk-query/usage/mutations.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Below are some of the most frequently used properties on the "mutation result" o
109109
- `isLoading` - When true, indicates that the mutation has been fired and is awaiting a response.
110110
- `isSuccess` - When true, indicates that the last mutation fired has data from a successful request.
111111
- `isError` - When true, indicates that the last mutation fired resulted in an error state.
112+
- `reset` - A method to reset the hook back to it's original state and remove the current result from the cache
112113

113114
:::note
114115

0 commit comments

Comments
 (0)