TypeError: Cannot read properties of null (reading 'formState')

Viewed 42

I'm creating a form using react-hook-form and I installed "@hookform/error-message": "^2.0.0" , and I got the above error I tried making a codesandbox and got the same error and then I removed @hookform/error-message but I'm still getting the error:

my form file:

import React, { useRef } from "react";
import { useForm } from "react-hook-form";

import { Paper } from "@mui/material";
import LoginInfo from "./loginInfo";

import CustomizedButtons from "./Button";

export default function Register() {
  const defaultValues = {
    fornavn: "",
    password: "",
    repeat_password: "",
    email: ""
  };

  const { control, watch, handleSubmit } = useForm({
    defaultValues
  });

  const password = useRef({});
  password.current = watch("password", "");

  const onSubmitSignIn = async (data) => {
    console.log(data);
  };

  return (
    <Paper elevation={3}>
      <form onSubmit={handleSubmit(onSubmitSignIn)}>
        <LoginInfo control={control} />
        <CustomizedButtons type="submit" label="REGISTER" />
      </form>
    </Paper>
  );
}

here is a link for the codesandbox

0 Answers
Related