diff --git a/src/react/useMutation.ts b/src/react/useMutation.ts index 1300e7e..e2ff316 100644 --- a/src/react/useMutation.ts +++ b/src/react/useMutation.ts @@ -13,6 +13,7 @@ export type Mutation = readonly [ config?: MutationExtraConfig, ) => Future>, AsyncData>, + { reset: () => void }, ]; export type MutationConfig = { @@ -48,5 +49,9 @@ export const useMutation = ( [client, stableMutation], ); - return [commitMutation, data]; + const reset = useCallback(() => { + setData(AsyncData.NotAsked()); + }, []); + + return [commitMutation, data, { reset }]; };