Skip to content

Commit 26a2647

Browse files
committed
docs: update callback return types to Promise<void> | void in mutation-related documentation
This commit refines the documentation for mutation-related callbacks (`onSuccess`, `onError`, `onSettled`, and `onMutate`), changing their return types from `Promise<unknown> | unknown` to `Promise<void> | void`.
1 parent 3a0ac8e commit 26a2647

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

docs/framework/react/plugins/persistQueryClient.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,12 @@ ReactDOM.createRoot(rootElement).render(
214214

215215
- `persistOptions: PersistQueryClientOptions`
216216
- all [options](#options) you can pass to [persistQueryClient](#persistqueryclient) minus the QueryClient itself
217-
- `onSuccess?: () => Promise<unknown> | unknown`
217+
- `onSuccess?: () => Promise<void> | void`
218218
- optional
219219
- will be called when the initial restore is finished
220220
- can be used to [resumePausedMutations](../../../../reference/QueryClient.md#queryclientresumepausedmutations)
221221
- if a Promise is returned, it will be awaited; restoring is seen as ongoing until then
222-
- `onError?: () => Promise<unknown> | unknown`
222+
- `onError?: () => Promise<void> | void`
223223
- optional
224224
- will be called when an error is thrown during restoration
225225
- if a Promise is returned, it will be awaited

docs/framework/react/reference/useMutation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ mutate(variables, {
6868
- This function will fire before the mutation function is fired and is passed the same variables the mutation function would receive
6969
- Useful to perform optimistic updates to a resource in hopes that the mutation succeeds
7070
- The value returned from this function will be passed to both the `onError` and `onSettled` functions in the event of a mutation failure and can be useful for rolling back optimistic updates.
71-
- `onSuccess: (data: TData, variables: TVariables, context: TContext) => Promise<unknown> | unknown`
71+
- `onSuccess: (data: TData, variables: TVariables, context: TContext) => Promise<void> | void`
7272
- Optional
7373
- This function will fire when the mutation is successful and will be passed the mutation's result.
7474
- If a promise is returned, it will be awaited and resolved before proceeding
75-
- `onError: (err: TError, variables: TVariables, context?: TContext) => Promise<unknown> | unknown`
75+
- `onError: (err: TError, variables: TVariables, context?: TContext) => Promise<void> | void`
7676
- Optional
7777
- This function will fire if the mutation encounters an error and will be passed the error.
7878
- If a promise is returned, it will be awaited and resolved before proceeding
79-
- `onSettled: (data: TData, error: TError, variables: TVariables, context?: TContext) => Promise<unknown> | unknown`
79+
- `onSettled: (data: TData, error: TError, variables: TVariables, context?: TContext) => Promise<void> | void`
8080
- Optional
8181
- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
8282
- If a promise is returned, it will be awaited and resolved before proceeding

docs/reference/MutationCache.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ Its available methods are:
2828

2929
**Options**
3030

31-
- `onError?: (error: unknown, variables: unknown, context: unknown, mutation: Mutation) => Promise<unknown> | unknown`
31+
- `onError?: (error: unknown, variables: unknown, context: unknown, mutation: Mutation) => Promise<void> | void`
3232
- Optional
3333
- This function will be called if some mutation encounters an error.
3434
- If you return a Promise from it, it will be awaited
35-
- `onSuccess?: (data: unknown, variables: unknown, context: unknown, mutation: Mutation) => Promise<unknown> | unknown`
35+
- `onSuccess?: (data: unknown, variables: unknown, context: unknown, mutation: Mutation) => Promise<void> | void`
3636
- Optional
3737
- This function will be called if some mutation is successful.
3838
- If you return a Promise from it, it will be awaited
39-
- `onSettled?: (data: unknown | undefined, error: unknown | null, variables: unknown, context: unknown, mutation: Mutation) => Promise<unknown> | unknown`
39+
- `onSettled?: (data: unknown | undefined, error: unknown | null, variables: unknown, context: unknown, mutation: Mutation) => Promise<void> | void`
4040
- Optional
4141
- This function will be called if some mutation is settled (either successful or errored).
4242
- If you return a Promise from it, it will be awaited
43-
- `onMutate?: (variables: unknown, mutation: Mutation) => Promise<unknown> | unknown`
43+
- `onMutate?: (variables: unknown, mutation: Mutation) => Promise<void> | void`
4444
- Optional
4545
- This function will be called before some mutation executes.
4646
- If you return a Promise from it, it will be awaited

0 commit comments

Comments
 (0)