Hey so I have a text box/FormControl that's supposed to update a field in a json in this.state. I was wondering if there was a better way to do onChange?
<FormControl
type='text'
placeholder='enter'
defaultValue={this.state.form.name}
onChange={this.handleChange.bind(this, 'name')}
/>
</FormGroup>
`
handleChange(change, event) {
var toChange = this.state.form;
toChange[change] = event.target.value;
this.setState({form: toChange});
}
this.setState({form: {...this.state.form, [change]: event.target.value}})
. That will be necessary if you implementshouldComponentUpdate
at some point for performance reasons. – Kimberleekimberley