diff --git a/packages/toolkit/src/query/react/buildHooks.ts b/packages/toolkit/src/query/react/buildHooks.ts index 110a534b92..07b067b6d0 100644 --- a/packages/toolkit/src/query/react/buildHooks.ts +++ b/packages/toolkit/src/query/react/buildHooks.ts @@ -825,17 +825,19 @@ export function buildHooks({ const originalArgs = fixedCacheKey == null ? promise?.arg.originalArgs : undefined const reset = useCallback(() => { - if (promise) { - setPromise(undefined) - } - if (fixedCacheKey) { - dispatch( - api.internalActions.removeMutationResult({ - requestId, - fixedCacheKey, - }) - ) - } + batch(() => { + if (promise) { + setPromise(undefined) + } + if (fixedCacheKey) { + dispatch( + api.internalActions.removeMutationResult({ + requestId, + fixedCacheKey, + }) + ) + } + }) }, [dispatch, fixedCacheKey, promise, requestId]) const finalState = useMemo( () => ({ ...currentState, originalArgs, reset }),