Skip to content
Discussion options

You must be logged in to vote

Thanks to @TalgatSaribayev 's comment on Stack Overflow for leading me to this solution.

I didn't need to set any specific validation rules for the address field and in the end I separated the sender and receiver forms into two different pages.

First, I've got to point out that instead of getting the input values of postalCode and address fields with the getValues API, I used the useWatch hook to get the most updated values.

// Watch inputs
const watchedInputs = useWatch({
  control,
  name: ['senderPostalCode', 'senderAddress'],
});

When I saved the input values with getValues in a variable, I got the previous state instead of the most recent one and the only way to solve that was calling

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@n-ii-ma
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by n-ii-ma
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
3 participants