Skip to content

Commit 3922bf8

Browse files
Update useMutation.js
1 parent dcc2797 commit 3922bf8

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/useMutation.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ export function useMutation(
6464
...useConfigContext(),
6565
...config,
6666
})
67+
68+
const getStatus = useGetLatest(state.status)
6769

6870
const mutate = React.useCallback(
6971
async (variables, options = {}) => {
72+
if (![statusIdle, statusSuccess, statusError].includes(getStatus())) {
73+
return
74+
}
75+
7076
dispatch({ type: actionMutate })
7177

7278
const resolvedOptions = {
@@ -92,7 +98,7 @@ export function useMutation(
9298
}
9399
}
94100
},
95-
[getConfig, getMutationFn]
101+
[getConfig, getMutationFn, getStatus]
96102
)
97103

98104
const reset = React.useCallback(() => dispatch({ type: actionReset }), [])

0 commit comments

Comments
 (0)