clearing errors object when to return errors: {} from a resolver
See original GitHub issueIs your feature request related to a problem? Please describe.
- mode: onChange
- use validationResolver
- have errors in more than one inputs
- validate all inputs by one of the inputs, and return
errors: {}
in the resolver
Currently errors: {}
doesn’t clear const {errors} = userForm()
this errors object entirely. resolver only updates the errors for the specific input you change.
Describe the solution you’d like
I would like to see errors
object being cleared to {}
by giving errors: {}
from a resolver.
Describe alternatives you’ve considered N/A
Additional context
https://codesandbox.io/s/react-hook-form-validationresolver-errors-j2iyu
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Error handling - Apollo GraphQL Docs
The unwrapResolverError function can remove the GraphQLError wrapping from a resolver error or return the error unaltered if it isn't from a resolver....
Read more >Resolve or Die - Error Handling Strategies for Loading Data in ...
If you are using a Route Resolver, and it encounters an unhandled exception, the route will not resolve, and your page will simply...
Read more >A Definitive Guide to Handling Errors in JavaScript - Kinsta
Getting tripped up by errors in your JavaScript? We'll show you how to tame those errors so you can get back to developing...
Read more >Error handling with promises - The Modern JavaScript Tutorial
In the task an error is thrown form inside the promise and promise is never settled neither with a resolve nor reject. The...
Read more >Best practice to return ApolloErrors from Nexus resolver
I'm currently struggeling with returning errors from my resolvers ... to return either the success value (like a user object) or an error....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
good point @github0013 i will re-open this issue and update the documentation, so others people aware of this issue and the reason behind this decision.
ok @github0013 i have completely my investigation. Short story, i think we will keep what we got for now. Let me explain the reason behind. Feel free to leave your thoughts as well.
The way we trigger re-render is based on error appear/disappear: https://github.com/react-hook-form/react-hook-form/blob/master/src/useForm.ts#L563 which is one of the performance enhancement for this library. If an error is persist then there is no need to re-render, so does when an error gets resolved, and it’s cheap to running against a single error at a time. We can invest into errors object comparison, but then it’s not efficient at least with my estimation for now. so for conclusion, we will keep as it for now.
let me know if this make sense.