react-custom-validation icon indicating copy to clipboard operation
react-custom-validation copied to clipboard

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

Open misogl opened this issue 6 years ago • 0 comments

I'm using [email protected] and [email protected].

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 avatar Jun 13 '18 15:06 misogl