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

issue: isValidating stuck in true state after initial render in 7.51.1 #11719

Closed
jbaldassari opened this issue Mar 26, 2024 · 3 comments
Closed
Labels
regression Regression with code change status: under investigation aware of this issue and pending for investigation

Comments

@jbaldassari
Copy link

Version Number

7.51.1

Codesandbox/Expo snack

https://codesandbox.io/p/sandbox/react-hook-form-isvalidating-stuck-7-51-1-w9p44c

Steps to reproduce

Version 7.51.1 introduced a regression in the state of isValidating on the first validation with defaultValues. Version 7.51.0 does not have this problem. I haven't been able to determine exactly what triggers the bug, but I suspect that having a nested field (preferences.theme in my sandbox example) has something to do with it because I can't reproduce it with the name field alone.

  1. Go to the code sandbox
  2. Observe that isValidating is true immediately upon loading, and no amount of form input will change it to false. The button will remain disabled until isValidating is false, isValid is true, and isDirty is true. The form state is output on screen and in the console.
  3. Roll back the version of react-hook-form from 7.51.1 to 7.51.0 in package.json, and observe that isValidating is now false on initial load, and that changing the values of the form field causes the submit button to become enabled.

Expected behaviour

isValidating should be false once the initial validation completes.

What browsers are you seeing the problem on?

Chrome

Relevant log output

SubmitButton::enabled: false {isDirty: false, isSubmitting: false, isValid: true, isValidating: true}


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
@jbaldassari
Copy link
Author

I think the issue must be related to #11624 or #11613, but I'm not sure which yet. If I have some time tomorrow I'll try to determine the exact commit that introduced it.

@priceratops05
Copy link

Hi, I was taking a look at the issues in the repo to avoid submitting the same issue twice.

I'm having the exact same issue, I have a useEffect that depends on isValid and isValidating to perform an automatic form submission but isValidating remains true, so my effect never triggers.

Thanks for all the hard work, I love using react hook form!

@bluebill1049 bluebill1049 added regression Regression with code change status: under investigation aware of this issue and pending for investigation labels Mar 26, 2024
@priceratops05
Copy link

Hey @bluebill1049, It seems that your that your changes are working as expected, however it looks like the isValid state is updating after the isValidating state, which leads to inconsistent states where the form is no longer validating, but the new isValid state hasn't been updated yet.

Is this behavior expected?

Untitled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression with code change status: under investigation aware of this issue and pending for investigation
Projects
None yet
Development

No branches or pull requests

3 participants