You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: standardize use of MaybePromise<T> in place of Promise<T> | T
This commit builds on the changes introduced in [refactor/narrow-callback-types](#9202) and replaces all instances of `Promise<T> | T` with the new `MaybePromise<T>` helper type. The `MaybePromise` type, originally defined in `@tanstack/query-persist-client-core/src/createPersister.ts`, is now moved to `query-core` for broader, consistent use.
- Moves the `MaybePromise` type definition to `query-core`, making it the canonical utility for representing values that may be returned synchronously or as a promise.
- Updates all relevant callback signatures (such as `onSuccess`, `onError`, `onMutate`, `onSettled`, and other callbacks) to use `MaybePromise<T>` instead of `Promise<T> | T`.
- Updates documentation to reference `MaybePromise<T>` for clarity and consistency.
This builds on the direction set by [refactor/narrow-callback-types](#9202), further improving type readability and maintainability by using a single, expressive type for all maybe-async callback returns.
Copy file name to clipboardExpand all lines: docs/framework/react/reference/useMutation.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,15 +68,15 @@ mutate(variables, {
68
68
- This function will fire before the mutation function is fired and is passed the same variables the mutation function would receive
69
69
- Useful to perform optimistic updates to a resource in hopes that the mutation succeeds
70
70
- 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.
0 commit comments