reset method doesn't update the subscriber of useWatch if defaultValue is provided
See original GitHub issueDescribe the bug
reset
method doesn’t update the watched field (by useWatch
) if a defaultValue is provided in the useWatch.
To Reproduce Steps to reproduce the behavior: (please use the codesandbox below)
- refresh the page
- wait for 3s for the
reset
method to get called - the subscriber to test field is updated with the new value
- if adding a default value to useWatch, the subscriber doesn’t get updated with the new value after calling reset
Codesandbox link https://codesandbox.io/s/funny-kalam-gf05v?file=/src/App.js
Expected behavior
I am not sure if this is a bug or an intended behavoir. However, I think in all cases calling reset
method should update the subscribers of useWatch
Desktop (please complete the following information):
- OS: macOs
- Browser firefox
- Version 80.0
Thank you for your hard work!
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
useWatch | React Hook Form - Simple React forms validation
Note: the first render will always return defaultValue when it's supplied. ... which means if you update a form value before the subscription...
Read more >why isn't the useWatch defaultValue not being overwritten?
I have the following code in one file and I am watching 2 fields to see if 1 or both are undefined and...
Read more >React Hook Form - Reset form with default values and clear ...
The solution is to use the reset() function from the React Hook Form library, if you execute the function without any parameters (...
Read more >React-Hook-Form Library | Common Use Cases
When the value gets provided, after clicking on the reset button, not only the value in the UI will be updated, but also...
Read more >React Hook Form - useForm: watch - YouTube
This session cover register API inside react hook form.Doc: https://react-hook-form.com/api/useform/watch.
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 FreeTop 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
Top GitHub Comments
It is clear now. Thank you for you time 😃
That’s what I meant above,
reset
API will reset thedefaultValues
, but withuseWatch
inlinedefaultValue
will take over that value.