Is there a way to programmatically reset the whole form and keep isValid true?
My scenario is the following:
I have a form with a few fields (different rules, but all of them are required fields).
I am using instantValidate
I have a button that clears the global state that holds the values of every single field.
What happens
Once I clear the values, <ValidatorComponent /> 's didUpdate understands prev and next props are different and starts the debounced validation cycle which results in isValid = false.
What I wanted
A way to clear the values + reset all validations, like a start again feature.
What I have tried
I have tried to use resetValidations(), but it runs before didUpdate lifecycle, therefore I end up with isValid = false anyways.
The only way I managed this to work was by placing resetValidations() inside a timeout :disappointed:
Things I would/wouldn't want to do:
I would like to keep using instantValidate
I wouldn't like to unmount the form and mount it again.
Is there a way to programmatically reset the whole form and keep isValid
true
?My scenario is the following:
What happens Once I clear the values,
<ValidatorComponent />
's didUpdate understands prev and next props are different and starts the debounced validation cycle which results inisValid
= false.What I wanted A way to clear the values + reset all validations, like a start again feature.
What I have tried I have tried to use
resetValidations()
, but it runs beforedidUpdate
lifecycle, therefore I end up withisValid
= false anyways.The only way I managed this to work was by placing
resetValidations()
inside a timeout :disappointed:Things I would/wouldn't want to do:
instantValidate