You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
When I type number in wrong pattern , the above code gives error array of size 2. Whereas, there should be one error. Normally, I take 1st index as error. In my code validate() is called dynamically using useEffect() which checks error each time useEffect hook runs
@silentrobi I saw your issue (although unrelated to mine) and since I'm working in a ReactJS project, I decided to reproduce your issue. TLDR, I couldn't:
The one differentiator between what you're doing and what I tried (since my setup is different), I validated outside of your hook. My suggestion would not to do an additional setFormState but to just define the errors and isValid on your component right above your return (that way they will recompute every time the component is rerendered).
Side note validate() returns an empty object when there are no errors. So, your ternary errors ? false : true will always be false because {} is truthy.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When I type number in wrong pattern , the above code gives error array of size 2. Whereas, there should be one error. Normally, I take 1st index as error. In my code validate() is called dynamically using useEffect() which checks error each time useEffect hook runs
My useEffect() hook
This is the React jsx code where I used it
The text was updated successfully, but these errors were encountered: