Trouble displaying a sum of values with useWatch
#2015
Unanswered
rickykenny
asked this question in
Q&A
Replies: 1 comment 4 replies
-
|
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have form that asks the user to provide their employment history, which is an array of objects including the date they started the job.
I want to show a message if the user hasn't provided 3 years worth of data.
Although I'll have validation for this as well, the message isn't a validation error; it's an info message.
I am using
useWatch
to watch the array and calculate the duration, but it doesn't always return the correct values, for example when an item is removed.watch
works better but the form in my project is quite large and I need the performance benefit ofuseWatch
.Am I doing something wrong here? Any help would be greatly appreciated :)
Here's a codesandbox: https://codesandbox.io/s/rhf-6-total-bg995?file=/src/people.jsx
You can toggle
watch
anduseWatch
inpeople.jsx
Repro steps:
Beta Was this translation helpful? Give feedback.
All reactions