Replies: 10 comments 12 replies
-
That's because you have field errors. {
"errors": {
"firstName": {
"type": "required",
"message": "",
"ref": {
"name": "firstName"
}
},
"lastName": {
"type": "required",
"message": "",
"ref": {
"name": "lastName"
}
}
}
} if you want to do something, when the form submission fails, make sure to provide a second const onInvalid = (errors) => console.error(errors)
handleSubmit(onSubmit, onInvalid) |
Beta Was this translation helpful? Give feedback.
-
Nope, already tried that, and does not print anything. Anything I pass to the handleSubmit function, does not execute. I was first playing with my own project example, but now Im just playing in the example of the documentation, and happens exactly the same. Both onSubmit nor onInvalid, does not execute |
Beta Was this translation helpful? Give feedback.
-
Hm.. can't reproduce in the Snack rhf-submit-callbacks-screencast.mp4 |
Beta Was this translation helpful? Give feedback.
-
which example is in the doc? it's working for me: https://snack.expo.dev/@bluebill1049/react-hook-form-v7---controller |
Beta Was this translation helpful? Give feedback.
-
Hm, I see a couple of thumbs up on the issue. Can someone confirm it's not working in this Snack? |
Beta Was this translation helpful? Give feedback.
-
Screen.Recording.2022-05-18.at.10.19.00.movI'm working on typescript, but it all should work pretty much the same. Here is my recording. I also show that the reset actions works good, but not the handleSubmit one. |
Beta Was this translation helpful? Give feedback.
-
it doesn't matter if it's typescript or not. please try to reproduce the issue in the snack above. |
Beta Was this translation helpful? Give feedback.
-
Here you have pretty much the same structure I have. The "EmailInputScreen.tsx" is where I pretty much copy pasted the example of the documentation to play with react-hook-form. It's in a screen rendered in a stackNavigator, you'll see that onSubmit nor onErrors are never called there. |
Beta Was this translation helpful? Give feedback.
-
update this codesandbox to reproduce the issue: https://snack.expo.dev/@bluebill1049/react-hook-form-v7---controller |
Beta Was this translation helpful? Give feedback.
-
I have a form in my component with some inputs and selects and i have some inputs which was not inside a form but i used register to get the data using watch, while submitting the form, the inputs which was not in the form is also restricting the form to submit, i got to know about the error using onInvalid is this the default behaviour of react-hook-form? |
Beta Was this translation helpful? Give feedback.
-
Version Number
7.31.1
Codesandbox/Expo snack
https://snack.expo.dev/@bluebill1049/react-hook-form-v7---controller
Steps to reproduce
Expected behaviour
onSubmit function should execute, and you should see the console.log output.
What browsers are you seeing the problem on?
No response
Relevant log output
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions