bhaRATh
bhaRATh

Reputation: 797

Property 'errors' does not exist on type 'UseFormReturn' in react-hook-form

When i use react-hook-form, i am unable to destructure error object from react-hook-form.

 const { register, handleSubmit, reset, setValue, getValues, errors, formState } = useForm({
        resolver: yupResolver(validationSchema)
    });

Upvotes: 7

Views: 8720

Answers (1)

bhaRATh
bhaRATh

Reputation: 797

i found answer in official docs. i.e.

 const { register, handleSubmit, reset, setValue, getValues, setError, formState: { errors }, formState } = useForm({
    resolver: yupResolver(validationSchema)
  });

Upvotes: 16

Related Questions