Instructor: We have a form which currently we can reset or submit. In this example, submit is basically a window alert, but in an actual application, it would be a network request or some server.
We would like to ensure that, when we submit the form, as long as the form submit action hasn't completed, we would not be able to submit the form again. Again, to achieve this effect, destructure the submitting property from React Final Form.
It is a Boolean value which lets us know whenever we are currently in the process of submitting the form or not. We are going to change the onSubmit function to simulate the network request.
It's going to return a new promise, which is going to be resolved after a timeout of a second. Inside of here, we're going to put the function that we had before our alert and resolve the promise.
Next, use the submitting property to disable the button whenever either on the form is pristine, or we are currently submitting the form. Let's see with an action. By putting our first name and the second name after I click submit, the button is disabled for a second.
Right now it's still disabled, because the submitting action hasn't finished yet. As soon as I click OK, I can go ahead and submit the form again. I can also reset it.