Search code examples
reactjsreact-hook-formyup

react-hook-form: Expected 6 arguments, but got 1


enter image description here

interface SampleProps {
  firstName: string;
  address: object;
  contact: string | Date | any;
}
const {
    register,
    handleSubmit,
    control,
    formState: { errors },
    getValues,
  } = useForm({
    resolver: yupResolver<SampleProps>(schema),
    defaultValues: {
      firstName: "",
    },
    mode: "onChange",
  });

I'm getting above error in yupResolver inside useForm().

What's wrong here and any help would be appreciated. Thanks


Solution

  • I fixed this a few months ago by downgrading

    @hookform/resolvers

    to version 3.1.1. Try downgrading your version too.

    {
      "@hookform/resolvers": "3.1.1",
      "react-hook-form": "7.49.3",
      "yup": "^1.3.3",
      "typescript": "^5.3.3"
    }