Interface: ReactMutation<Mutation>
react.ReactMutation
An interface to execute a Convex mutation function on the server.
Type parameters
Name | Type |
---|---|
Mutation | extends FunctionReference <"mutation" > |
Callable
ReactMutation
▸ ReactMutation(...args
): Promise
<FunctionReturnType
<Mutation
>>
Execute the mutation on the server, returning a Promise
of its return value.
Parameters
Name | Type | Description |
---|---|---|
...args | OptionalRestArgs <Mutation > | Arguments for the mutation to pass up to the server. |
Returns
Promise
<FunctionReturnType
<Mutation
>>
The return value of the server-side function call.
Defined in
Methods
withOptimisticUpdate
▸ withOptimisticUpdate(optimisticUpdate
): ReactMutation
<Mutation
>
Define an optimistic update to apply as part of this mutation.
This is a temporary update to the local query results to facilitate a fast, interactive UI. It enables query results to update before a mutation executed on the server.
When the mutation is invoked, the optimistic update will be applied.
Optimistic updates can also be used to temporarily remove queries from the client and create loading experiences until a mutation completes and the new query results are synced.
The update will be automatically rolled back when the mutation is fully completed and queries have been updated.
Parameters
Name | Type | Description |
---|---|---|
optimisticUpdate | OptimisticUpdate <FunctionArgs <Mutation >> | The optimistic update to apply. |
Returns
ReactMutation
<Mutation
>
A new ReactMutation
with the update configured.