Skip to content

Commit

Permalink
fix(useMutation): Making parameters optional
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Sep 27, 2023
1 parent 1678577 commit b085cc7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion docs/api/cozy-client/README.md
Expand Up @@ -116,7 +116,7 @@ Use those fetch policies with `<Query />` to limit the number of re-fetch.

#### Call signature

▸ (`__namedParameters`): `UseMutationReturnValue`
▸ (`__namedParameters?`): `UseMutationReturnValue`

This hook manages the state during the saving of a document

Expand All @@ -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*

Expand Down
2 changes: 1 addition & 1 deletion packages/cozy-client/src/hooks/useMutation.jsx
Expand Up @@ -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<import("../types").QueryFetchStatus>} */
Expand Down
6 changes: 3 additions & 3 deletions packages/cozy-client/types/hooks/useMutation.d.ts
Expand Up @@ -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 {
Expand Down

0 comments on commit b085cc7

Please sign in to comment.