formsy-react-components
formsy-react-components copied to clipboard
onChange is called before the value has been set on formsy
This leads to problems where the previous value is flashed after a change if I call setState in my onChange function. This happens because the component is re-rendered, and formsy passes the value before change to the Input, leading the input to update it state w/ the previous value. Then the formsy setValue finishes, and the input updates its state again using the updated value.
handleOnChange(name, value) {
this.setState({pending: true})
... some async check
this.setState({pending: false, result})
}
render() {
<Input name='name' onChange={this.handleOnChange.bind(this)}/>
}