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

onValid function passed to $submit can be called twice when using async validations #52

Open
misogl opened this issue Jun 13, 2018 · 0 comments

Comments

@misogl
Copy link
Member

misogl commented Jun 13, 2018

I'm using react-custom-validation@0.5.7 and react@16.3.1.

This happens when submit occurs while the validation result is still undetermined.

The following events happen in the library:

  1. dispatchUpdate is called from setTimeout
  2. form is valid so onValid gets called and changes the redux state
  3. change in redux state causes render of the parent of validate form
  4. this causes call of componentWillReceiveProps in validated HOC
  5. dispatchUpdate is called again but the register is still in submitting state (call of onValid has not finished yet)

I was able to reproduce this issue only when running cypress tests as the async validation is quite fast.

@misogl misogl changed the title onValid function passed to $submit can be called twice when using async validations onValid function passed to $submit can be called twice when using async validations Jun 13, 2018
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