-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Improve watch
to reflect overloads
#1056
Improve watch
to reflect overloads
#1056
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Ty
Does this address issue #1040? It's probably worth documenting the Also, TypeScript gives this as the type for watch: export type WatchObserver<TFieldValues extends FieldValues> = (value: DeepPartial<TFieldValues>, info: {
name?: FieldPath<TFieldValues>;
type?: EventType;
values?: unknown;
}) => void; What is Slightly unrelated: Why is Currently, I'm doing this to easily access nested properties: useEffect(() => {
const subscription = watch((value, { name, type }) => {
const actualValues = getValues();
});
return () => subscription.unsubscribe();
}, [watch]); |
relates to #1040
I tried to make description in https://react-hook-form.com/docs/useform/watch to reflect real overload of the function according to its JSDoc
I'm not sure about description, but I'm sure it would be better if organized like this, because it has two different usages, which, without explanation, may lead beginners to confusion.
I'm willing to make some additional edit if needed to make description more precise.