How to prevent parallel async submission? #3921
Unanswered
KonstantinVlasov
asked this question in
Q&A
Replies: 1 comment
-
Since There are several strategies for achieving that depending on what you need to do. If you are looking to prevent by having only one active submission then you can do it like this. const { handleSubmit } = useForm();
const submitHandler = handleSubmit(values => {
// ...
});
let ongoingSubmission;
// only one submission can be outgoing.
async function onSubmit() {
ongoingSubmission = ongoingSubmission || submitHandler();
await ongoingSubmission;
ongoingSubmission = null;
} Slight variations might give you different results. But if all you are interested in is the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
handleSubmit starts every time a valid form submitted. Even if previous async submit not completed yet. How can I prevent this behaviour? Creating own isSubmitting looks weird.
Beta Was this translation helpful? Give feedback.
All reactions