I have the following code:
constructor(props) {
super(props);
this.state = {
search: "",
value: "",
username:'',
email:'',
password: '',
};
this.onChange = this.onChange.bind(this);
this.onSubmit = this.onSubmit.bind(this);
}
...
...
onChange(e) {
this.setState(
{[e.target.name]: e.target.value})
}
...
...
<input type="password" placeholder="Password"
onChange={e => this.onChange(e)}
value={ this.state.password }
/>
But I can't type into the password field.
If I remove the value={ this.state.password }
part I can then type into the field, but it seems like my state isn't being updated when this field is changed.
What is the problem?