New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reset
method does not affect Controller
-wrapped components
#960
Comments
your CSB is broken, also for reset with the controller component, you will need to declare the fields.
|
looks CSB itself having issue. |
That complicates things. I have a form that loads in "read only" mode with an However, if I click Sounds like maybe that is beyond the scope of |
It’s one of trade offs with uncontrolled inputs or components, especially when default values are not supplied, react hook form won’t be able to assume the default value for such reset. I will take a look your description above closely tonight @bopfer |
No hurry, I know you are busy. I have plenty of other stuff to work on as well 😄 |
I will update the documentation tonight as well: With controller components, it’s more ideal to supply reset values when default values are not supplied. |
In my case default values are supplied. It seems to me that reset values are mandatory for controller components. |
in your case |
Thanks for the detailed explanation as usual @bopfer most likely you will have to supply the defaultValues for react hook form to reset correctly. |
going to close this issue and update the doc. |
I updated the csb and the issue still persists. |
i tested your example and it works... |
I must confess - the more I play with I updated the csb again with 2 forms:
|
That's not even an input component... i am more than happy to help, but try to follow the lib docs, that will make my life and yours easier. if still having issue have a look at the source code may help you as well. if you spot issue, feel free to send a PR as well to help everyone.
|
I got Thank you for your patience. |
This was a saviour :) Thank you very much. great work :) |
This is what I found. no
|
Describe the bug
If the
reset
method is invoked the components wrapped inController
won't receive the default value; instead they keep getting their current value.To Reproduce
Controller
reset
methodCodesandbox link
https://codesandbox.io/s/optimistic-sea-dppb6
Change this value in the input field and click on the "Click" button.
When clicking on the "Reset"-Button, the input field resets to
default
but the field next to "Click" does not reset to-1
Expected behavior
Desktop (please complete the following information):
Additional context
The API documentation implies that it should work with
Controller
s: https://react-hook-form.com/api/#resetThe text was updated successfully, but these errors were encountered: