onError and useForm errors behaviour for React #1327
Unanswered
martinszemitis
asked this question in
Help (React)
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Huh...
After spending few mornings on the issue I finally found how onError and useForm should be used with the current React adapter version.
Steps to reproduce the problem:
Outcome:
onError is triggered
global errors object is empty
but when you fail validation a second time, the errors object is filled with error messages
Solution:
This code will not reset form fields the first time you load a component and enter the wrong data:
This will work every time:
Why it took so long for me to find it? I was looking at Jetstream Vue implementation, and it uses global errors object and it works.
@claudiodekker, @reinink is it because of React-specific behavior that it doesn't work the same as for Vue?
I think some examples in the documentation for onError usage with errors passed in, would be a great addition.
Beta Was this translation helpful? Give feedback.
All reactions