I have useform hook , where I am getting an errors object. So I am trying to pass it to other componenet.
const {
register,
handleSubmit,
watch,
control,
formState: { errors, isDirty, isValid }
} = useForm<CampaignForm>({
mode: 'all',
resolver: yupResolver(validationSchema),
defaultValues: {
[FormFields.StartDate]: null,
[FormFields.EndDate]: null,
[FormFields.StartTime]: null,
[FormFields.EndTime]: null,
[FormFields.Locations]: `${strings.campaign.createCampaign.allRetailLocation}`
}
})
<Campaigon erros={errors} register={register}/>
interface is :
interface ICampaign {
register: any
errors: any
}
here, I am using anyas a type for both. So, what should be the type for register and errors.
Thanks for the help.
You don’t have to pass a type into the useForm hook. You can allow TS to infer types here.