react-query-firebase / react-native/firestore / useAddDocMutation
Function: useAddDocMutation()
ts
function useAddDocMutation<AppModelType, TContext>(options): UseMutationResult<AppModelType, NativeFirebaseError, {
data: WithFieldValue<AppModelType>;
}, TContext>;
Defined in: react-native/firestore/useAddDocMutation.ts:65
Executes a mutation and returns added document
Type Parameters
AppModelType
AppModelType
extends AppModel
= AppModel
TContext
TContext
= unknown
Parameters
options
Configuration options for the mutation.
collectionReference
CollectionReference
<AppModelType
>
Reference to a collection where document must be added
options?
Omit
<UseMutationOptions
<AppModelType
, NativeFirebaseError
, { data
: WithFieldValue
<AppModelType
>; }, TContext
>, "mutationFn"
> = {}
Options for useMutation hook excluding mutationFn. MutationKey will be equal to reference.path by default.
Returns
UseMutationResult
<AppModelType
, NativeFirebaseError
, { data
: WithFieldValue
<AppModelType
>; }, TContext
>
A mutation result
Example
jsx
export const MyComponent = () => {
const {mutate} = useAddDocMutation({
options: {
},
reference: collection(),
});
// ....
mutate({data: {test: 'value'}});
// ....
};