I'm making a simple form that I want to act when enter is pressed, but for some reason it only works on the second enter press, instead of the first
render() for component:
render() {
return (
<form onSubmit={this.handleSubmit}>
<FormGroup controlId="formBasicText">
<ControlLabel>MyLabel</ControlLabel>
<FormControl
type="text"
value={this.state.value}
placeholder="Enter something"
onChange={this.handleChange}
/>
<FormControl.Feedback />
</FormGroup>
</form>
);
}
handleSubmit() :
handleSubmit(e) {
e.preventDefault();
myMethod({this.state.value});
}
Why is this only working on the second enter press?
Edit: To be clear, this is only a subset of the object code. Trying to run just this is of course going to fail. I just think whatever is going wrong is likely in either the render of the object or the handleSubmit method.
Just in case, here is the constructor:
constructor(props) {
super(props);
this.state = {
value: "",
};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}