Can not submit form react-bootstrap Can not submit form react-bootstrap reactjs reactjs

Can not submit form react-bootstrap


FormGroup does not provide on submit event. You can wrap it with form element and attach event handler to it:

<form onSubmit={this.gotEmail}>  <FormGroup role="form">    <FormControl type="text" className="form-control"/>    <Button className="btn btn-primary btn-large centerButton" type="submit">Send</Button>  </FormGroup></form>


There is one thing missing, I think.

In gotEmail, there should be a preventDefault, so if the user press 'enter', the page won't reload:

gotEmail(event){   event.preventDefault();  // code you want to do}


As of version 0.30.2, you can wrap it in a <Form>, which supports the onSubmit property:

<Form onSubmit={this.gotEmail}>  <FormGroup role="form">  <FormControl type="text" className="form-control"/>  <Button className="btn btn-primary btn-large centerButton"   type="submit">Send</Button>  </FormGroup></Form>