Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document watch callback type parameter #1040

Open
vladev opened this issue Jan 10, 2024 · 0 comments
Open

Document watch callback type parameter #1040

vladev opened this issue Jan 10, 2024 · 0 comments

Comments

@vladev
Copy link

vladev commented Jan 10, 2024

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!

@vladev vladev changed the title Document watch type callback parameter Document watch callback type parameter Jan 10, 2024
@Moshyfawn Moshyfawn transferred this issue from react-hook-form/react-hook-form Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants