Skip to content

react-query-firebase / web/firestore / useUpdateDocMutation

Function: useUpdateDocMutation()

ts
function useUpdateDocMutation<AppModelType, TContext>(options): UseMutationResult<AppModelType & object, FirebaseError, {
  data: UpdateData<AppModelType>;
}, TContext>;

Defined in: web/firestore/useUpdateDocMutation.ts:59

Executes a mutation and returns updated document

Type Parameters

AppModelType

AppModelType extends AppModel = AppModel

TContext

TContext = unknown

Parameters

options

Configuration options for mutation.

options?

Omit<UseMutationOptions<AppModelType, FirebaseError, { data: UpdateData<AppModelType>; }, TContext>, "mutationFn"> = {}

Options for useMutation hook excluding mutationFn.

reference

null | DocumentReference<AppModelType, AppModelType>

Reference to a document that must be updated

Returns

UseMutationResult<AppModelType & object, FirebaseError, { data: UpdateData<AppModelType>; }, TContext>

A mutation result

Example

jsx
export const MyComponent = () => {
 const {mutate} = useUpdateDocMutation({
     options: {
     },
     reference: collection().doc(),
 });

 // ....
 mutate({data: {test: 'value'}});
 // ....
};

Released under the MIT License.