Skip to content

Commit f828528

Browse files
authored
fix(types): change MutateOptions return types to void (#4133)
* Docs: Update mutate options description * fix(types): change MutateOptions return types to void * fix(types): undo context param type change for mutate onSuccess * style: run prettier for types
1 parent 0c27646 commit f828528

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

docs/reference/useMutation.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,18 @@ mutate(variables, {
9797
- `variables: TVariables`
9898
- Optional
9999
- The variables object to pass to the `mutationFn`.
100-
- Remaining options extend the same options described above in the `useMutation` hook.
100+
- `onSuccess: (data: TData, variables: TVariables, context: TContext) => void`
101+
- Optional
102+
- This function will fire when the mutation is successful and will be passed the mutation's result.
103+
- Void function, the returned value will be ignored
104+
- `onError: (err: TError, variables: TVariables, context: TContext | undefined) => void`
105+
- Optional
106+
- This function will fire if the mutation encounters an error and will be passed the error.
107+
- Void function, the returned value will be ignored
108+
- `onSettled: (data: TData | undefined, error: TError | null, variables: TVariables, context: TContext | undefined) => void`
109+
- Optional
110+
- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
111+
- Void function, the returned value will be ignored
101112
- If you make multiple requests, `onSuccess` will fire only after the latest call you've made.
102113
- `mutateAsync: (variables: TVariables, { onSuccess, onSettled, onError }) => Promise<TData>`
103114
- Similar to `mutate` but returns a promise which can be awaited.

packages/query-core/src/types.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -576,22 +576,18 @@ export interface MutateOptions<
576576
TVariables = void,
577577
TContext = unknown,
578578
> {
579-
onSuccess?: (
580-
data: TData,
581-
variables: TVariables,
582-
context: TContext,
583-
) => Promise<unknown> | unknown
579+
onSuccess?: (data: TData, variables: TVariables, context: TContext) => void
584580
onError?: (
585581
error: TError,
586582
variables: TVariables,
587583
context: TContext | undefined,
588-
) => Promise<unknown> | unknown
584+
) => void
589585
onSettled?: (
590586
data: TData | undefined,
591587
error: TError | null,
592588
variables: TVariables,
593589
context: TContext | undefined,
594-
) => Promise<unknown> | unknown
590+
) => void
595591
}
596592

597593
export type MutateFunction<

0 commit comments

Comments
 (0)