Set watch callback event type when calling setValue #12197
Unanswered
BrendanC23
asked this question in
Ideas
Replies: 1 comment
-
I'd give this one +1 My situation is the following. I'm using Redux to keep track of the changes inside react-hook-form. Also, when initializing the form, the values come from Redux selectors. watch() is used to dispatch any changes to Redux. This all works fine. Now, the values inside Redux may be changed from another component by dispatching an action. I then update the form values using useSelector() and setValue() and I need to avoid watch() dispatching the data again to Redux by checking type. But yes, type is undefined when I use setValue(). Is there any way to achieve that? Currently it just results in an endless hook loop... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The
form.watch(callback)
function has an event type parameter, which is usually set tochange
for user-triggered inputs. When the form is updated usingsetValue
, the type isundefined
. I would like to be able to pass a custom change type tosetValue
andreset
.There is a similar issue from 2022: #9363 that I would like to bring attention to.
setValue('fieldName', newValue, { changeType: 'newChangeTypeOverride' });
Beta Was this translation helpful? Give feedback.
All reactions