documentation
documentation copied to clipboard
Document watch callback type parameter
Is your feature request related to a problem? Please describe.
Using the watch
API in useEffect
like so:
useEffect(() => {
watch((data, {name, type}) => {
console.log(data, name, type)
})
})
It seems type
indicates who initiated the update, because a user change results in type: 'change'
, while a setValue
call results in type: undefined
. I'm actually using it avoid endless watch calls as I call setValue
inside watch
, which results in a new watch
callback call. I'd like to ask for documentation of this type
field.
Describe the solution you'd like
Document the possible options for the type
attribute in watch
callback.
Describe alternatives you've considered
I can probably hunt down all usages within the code but it seems suboptimal. The current documentation just mentions the presence of this field and it's even typed as just string
, which doesn't convey much information about it.
Additional context React Hook Form seems like a really neat and advanced library - well done!