Submitting forms

Now that we have our form ready, let's take the next logical step and figure out how to submit the data to our API.

The first thing we need to do is to add an onSubmit event handler to the form. The handler is specific to the registration form, and thus should be associated with RegistrationForm. The most obvious place to define it is as a class method. Update RegistrationForm to the following:

class RegistrationForm extends React.Component {  handleRegistration = (event) => {    event.preventDefault();    event.stopPropagation();  }  render() {    return (      <form onSubmit={this.handleRegistration}>        <Input label="Email" type="email" />        <Input label="Password" type="password" />        <Button title="Register" />      </form>    )  }}

this.handleRegistration ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.