isValid can't be initialized to false #10913
Unanswered
Rayah-Flare
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I have an input form, a Zip Code component with a submit button.
I want to validate the input before submitting it. Therefore, the button must be disabled until the input is valid (i.e. an address is returned by the API and the zip code is valid).
I implemented it with a
useEffect()
which checks the value of the address.If the address isn't valid yet (which is the case also from the beginning since we don't have values yet), it calls
setError()
.Else, it calls
clearErrors()
andtrigger()
.However, this is not working. the button is enabled from the beginning and
isValid = true
even if theformState.erros
is not empty.Any idea how can I fix this?
Beta Was this translation helpful? Give feedback.
All reactions