Replies: 1 comment
-
export declare function useWatch<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: {
name: TFieldName;
defaultValue?: FieldPathValue<TFieldValues, TFieldName>;
control?: Control<TFieldValues>;
disabled?: boolean;
exact?: boolean;
}): FieldPathValue<TFieldValues, TFieldName>; Does something like this work? export const CreateProfileButton = <TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ control, name }: { control: Control<TFieldValues>; name: TFieldName }) => {
const formValues = useWatch({ control, name })
const isButtonDisabled = formValues.every((value: string | boolean) => value)
return (
<Button disabled={!isButtonDisabled} type="submit" >
Create Profile
</Button>
)
} |
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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a form with 5 to 6 fields. If all field are field then i want to enable the Create Profile button and vice verssa. For this i decided to make a common component pass control and name a props but i am getting error for name
Here is error:
I will use CreateProfileButton for 4 to 5 more compoennts.
how can i give type to name ? or is there any better way?
Beta Was this translation helpful? Give feedback.
All reactions