issue: Needed to click submit twice for errors to appear when there is no parameter and using formState: { errors } directly. #11346
Replies: 3 comments
-
The The const {
- formState: { errors },
} = useForm()
- function handleError() {
+ function handleError(errors) {
for (const error of Object.values(errors)) {
toast.error(error.message)
}
} |
Beta Was this translation helpful? Give feedback.
-
Yes I understand, like I stated in my post you can fix it with adding that parameter. Thanks |
Beta Was this translation helpful? Give feedback.
-
It is the expected behavior with how RHF priorities render optimization at this time |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Version Number
^7.49.2
Codesandbox/Expo snack
https://codesandbox.io/p/sandbox/trusting-archimedes-fly5hk?file=%2Fsrc%2FApp.js%3A64%2C11
Steps to reproduce
Expected behaviour
The errors should appear on the first click.
What browsers are you seeing the problem on?
Firefox, Chrome, Safari, Edge
Relevant log output
The issue is able to be fixed with the following
Add a parameter
errors
to the handleError function.Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions