File tree Expand file tree Collapse file tree 3 files changed +5
-2
lines changed Expand file tree Collapse file tree 3 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -323,7 +323,7 @@ type UseMutationTrigger<T> = (arg: any) => Promise<
323
323
requestId: string // A string generated by RTK Query
324
324
abort: () => void // A method to cancel the mutation promise
325
325
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
327
327
}
328
328
329
329
type UseMutationResult <T > = {
@@ -340,6 +340,8 @@ type UseMutationResult<T> = {
340
340
isSuccess: boolean // Mutation has data from a successful call
341
341
isError: boolean // Mutation is currently in an "error" state
342
342
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
343
345
}
344
346
` ` `
345
347
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ import { toast } from 'your-cool-library'
94
94
export const rtkQueryErrorLogger: Middleware = (api : MiddlewareAPI ) => (
95
95
next
96
96
) => (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!
98
98
if (isRejectedWithValue (action )) {
99
99
console .warn (' We got a rejected action!' )
100
100
toast .warn ({ title: ' Async error!' , message: action .error .data .message })
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ Below are some of the most frequently used properties on the "mutation result" o
109
109
- ` isLoading ` - When true, indicates that the mutation has been fired and is awaiting a response.
110
110
- ` isSuccess ` - When true, indicates that the last mutation fired has data from a successful request.
111
111
- ` 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
112
113
113
114
:::note
114
115
You can’t perform that action at this time.
0 commit comments