We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dcc2797 commit 3922bf8Copy full SHA for 3922bf8
1 file changed
src/useMutation.js
@@ -64,9 +64,15 @@ export function useMutation(
64
...useConfigContext(),
65
...config,
66
})
67
+
68
+ const getStatus = useGetLatest(state.status)
69
70
const mutate = React.useCallback(
71
async (variables, options = {}) => {
72
+ if (![statusIdle, statusSuccess, statusError].includes(getStatus())) {
73
+ return
74
+ }
75
76
dispatch({ type: actionMutate })
77
78
const resolvedOptions = {
@@ -92,7 +98,7 @@ export function useMutation(
92
98
}
93
99
94
100
},
95
- [getConfig, getMutationFn]
101
+ [getConfig, getMutationFn, getStatus]
96
102
)
97
103
104
const reset = React.useCallback(() => dispatch({ type: actionReset }), [])
0 commit comments