Progressive Enhancement Techniques for React Part 2
In my previous post, I detailed some techniques for progressive enhancement for React. This post is sort of part 1.1: it’s a continuation on form handling.
More Complicated Forms
In the previous example, we had a form with a single submit button. However, it’s common that forms have multiple buttons that perform different actions but share some input fields. Imagine a form that has a field for your current password, a new password, and buttons to change the password and delete your account.
Below is a form demonstrating it. There’s a hidden input called id, so it would make sense for the update and delete buttons to both be included in the same form.

On the server, this would be handled by giving each button the same name, but different values. The value of the button would show up under the key of the name with a corresponding value.
The browser implementation of the form is very similar to the previous. However, instead of using the onSubmit handler on the form, we use onClick handlers for each button.
Note that to continue using uncontrolled components as last time, we have to use the property defaultValue instead of value for inputs.
