question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

issue: changing name of useWatch doesn't change anything

See original GitHub issue

Version Number

7.33.1

Codesandbox/Expo snack

https://codesandbox.io/s/sparkling-snow-z06xpt?file=/src/App.js

Steps to reproduce

  1. create component with useWatch
  2. change name of fields which watch are needed

Expected behaviour

react-hook-form resubscribe for new fields when name parameter in useWatch hook was changed.

What browsers are you seeing the problem on?

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project’s Code of Conduct

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Moshyfawncommented, Jul 12, 2022

Expected behavior. The name value is used to subscribe to a specific input; it’s not dynamic.

You should have multiple subscriptions instead. For optimization purposes you can make use of the disabled prop to toggle the subscription depending on your use-case condition

1reaction
nobodywithbodycommented, Jul 13, 2022

thanks for the suggestion, no plan to further increase the API surface at the current version.

  • virtualise your render with react-window or react-virtual
  • use watch() callback if no re-render is required.

Thank you for your solution. I guess watch() callback is gonna work for a while. BTW, many thanks for this library! You’ve done great work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

useWatch value not updated after reset #3205 - GitHub
However when I update to the latest react-hook-form, 6.9.4 It does not work as expected. The useWatch value is not updated!
Read more >
useWatch | React Hook Form - Simple React forms validation
useWatch 's execution order matters, which means if you update a form value before the subscription is in place, then the value updated...
Read more >
React Hook Form useWatch not displaying correct value in ...
For anyone that may have this issue, I was able to fix it by using setValues to initially set the value on render...
Read more >
React Hook Form - useForm: watch - YouTube
If playback doesn't begin shortly, try restarting your device. Your browser can't play this video. ... UseWatch. UseWatch. 7:04 ...
Read more >
Form - Ant Design
Name (Watch to trigger rerender). Age (Not Watch). Name Value: Watch Hooks. useWatch helps watch the field change and only re-render for the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found