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
fix(useWatch): default value for array of inputs #9555
fix(useWatch): default value for array of inputs #9555
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
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.
Looking great! thanks a lot for the fix.
src/useWatch.ts
Outdated
const [value, updateValue] = React.useState<unknown>( | ||
isUndefined(defaultValue) | ||
? control._getWatch(name as InternalFieldName) | ||
: defaultValue, | ||
: control._getWatch( | ||
name as InternalFieldName, | ||
defaultValue as DeepPartialSkipArrayKey<TFieldValues>, | ||
), | ||
); |
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.
I think we can simplify to the following
const [value, updateValue] = React.useState<unknown>(
control._getWatch(
name as InternalFieldName,
defaultValue as DeepPartialSkipArrayKey<TFieldValues>,
),
);
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.
Let's go! Thanks.
Thank you @bluebill1049! |
@bluebill1049 when will it be released? |
I am planning to do the final release of the year next week. |
Closes #9530