diff --git a/docs/api/cozy-client/README.md b/docs/api/cozy-client/README.md index c5c6ec5f6..75892c94a 100644 --- a/docs/api/cozy-client/README.md +++ b/docs/api/cozy-client/README.md @@ -116,7 +116,7 @@ Use those fetch policies with `` to limit the number of re-fetch. #### Call signature -▸ (`__namedParameters`): `UseMutationReturnValue` +▸ (`__namedParameters?`): `UseMutationReturnValue` This hook manages the state during the saving of a document @@ -125,6 +125,8 @@ This hook manages the state during the saving of a document | Name | Type | | :------ | :------ | | `__namedParameters` | `Object` | +| `__namedParameters.onError` | `any` | +| `__namedParameters.onSuccess` | `any` | *Returns* diff --git a/packages/cozy-client/src/hooks/useMutation.jsx b/packages/cozy-client/src/hooks/useMutation.jsx index bb1dd44aa..653500108 100644 --- a/packages/cozy-client/src/hooks/useMutation.jsx +++ b/packages/cozy-client/src/hooks/useMutation.jsx @@ -8,7 +8,7 @@ import useClient from './useClient' * * @returns {import("../types").UseMutationReturnValue} */ -const useMutation = ({ onSuccess, onError }) => { +const useMutation = ({ onSuccess = undefined, onError = undefined } = {}) => { const client = useClient() /** @type {import("../types").useState} */ diff --git a/packages/cozy-client/types/hooks/useMutation.d.ts b/packages/cozy-client/types/hooks/useMutation.d.ts index ec92ce39a..442f290eb 100644 --- a/packages/cozy-client/types/hooks/useMutation.d.ts +++ b/packages/cozy-client/types/hooks/useMutation.d.ts @@ -3,9 +3,9 @@ * * @returns {import("../types").UseMutationReturnValue} */ -export function useMutation({ onSuccess, onError }: { - onSuccess: any; - onError: any; +export function useMutation({ onSuccess, onError }?: { + onSuccess?: any; + onError?: any; }): import("../types").UseMutationReturnValue; export namespace useMutation { namespace propTypes {