#Reset form level errorMap
15 messages · Page 1 of 1 (latest)
but it doesn't allow resetting errors
It doesn't acceptsetErrorMap({})?
also, what do you intend to use it for?
it does accept setErrorMap({}) but it doesn't do anything.
i have a form with steppers. I need to reset the form on moving to a new step
ah, just checked the code. Looks like Object.entries(yourParam) is called, so for that it would become []
Does one with every key set to undefined work?
a form.reset() could also be a clean approach if it's a stepped form. If you keep defaultValues as external state to make sure it contains the latest saved data
yeah it seems like forn.reset() could help if i pass the data back to it from somehwere else.
Does one with every key set to undefined work?
every key, meaningonSubmit,onBluretc?
no, it doesn't, as passing empty object to those handlers still makes them appear in errorMap with empty value
yeah, was thinking something like
setErrorMap({ onMount: undefined, /* ... */ })
yeah that was the first thing i tried, didn't help\
actually, seems like passing undefined does the trick! i tried with {} / []
thanks 🙂
yup, that makes a difference in JavaScript
I could've sworn that this was done internally at some point, but good to hear it's not broken on the outside
well, a little bit broken.
yeah just need to pass to each key explicitly