Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onChange is called before the value has been set on formsy #132

Open
ewingrj opened this issue Apr 16, 2019 · 0 comments
Open

onChange is called before the value has been set on formsy #132

ewingrj opened this issue Apr 16, 2019 · 0 comments

Comments

@ewingrj
Copy link

ewingrj commented Apr 16, 2019

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)}/>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant