Skip to content
Discussion options

You must be logged in to vote

Consider lifting setValue out of the child or switch the order of <ComponentA /> and <ComponentB /> around, so that the component using useWatch is before the setValue call. It's the expected behavior. See Rules section of RHF useWatch docs section:

useWatch execution order matters, which means if you are update form value before the subscription is in place, then the value update will be ignored.

setValue('test', 'data');
useWatch({ name: 'test' }); // ❌ subscription is happened after value update, no update received

useWatch({ name: 'example' }); // ✅ input value update will be received and trigger re-render
setValue('example', 'data'); 

Replies: 6 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@hokwanhung
Comment options

Answer selected by Moshyfawn
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@bluebill1049
Comment options

@Moshyfawn
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #7640 on February 02, 2022 22:39.