onInputChange (e) {
this.setState({ username: e.target.value });
}
onInputChange2 (e) {
this.setState({ email: e.target.value });
}
onInputChange3 (e) {
this.setState({ password: e.target.value });
}
Inputs
<input type="text" required className="form-control" placeholder="Username" onChange={this.onInputChange.bind(this)} />
<input type="email" required className="form-control" placeholder="Email" onChange={this.onInputChange2.bind(this)} />
<input type="password" required className="form-control" placeholder="Password" onChange={this.onInputChange3.bind(this)} />
Associate a single listener for all controlled inputs and by
bind
passing the name of the property to which it corresponds in the state:Since you've used
bind
to pass arguments, you still hold the parameterevent
: