Replies: 1 comment
-
Please can somebody confirm the official stance on this issue? Or is anything needed from me? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I was wondering why calling reset function to clear form state is causing re-renders of all useFormContext subscribers?
I have a button to clear my form. I thought I can use reset function, but all components using useFormContext (and useForm and consequently FormProvider) trigger re-render the moment I call reset function.
I am looking for a way to clear my form state and I was able to write function, that walksthrough all my fields and calls
setValue(fieldName, defaultValues[fieldName]); clearErrors(fieldName)
That solution does not cause any unnecessary re-renders.
I was about to write some abstract solution/function to do this for any form provided. But I must say, this is too complicated and too frequent use case for me to be on correct path.
So my question in - am I doing something wrong? Did I miss the correct approach somewhere along the way?
Beta Was this translation helpful? Give feedback.
All reactions