Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

React-Hook-Form useForm is not a function

I am using NextJs 14 and React Hook Form and I keep running in this error

I used the guide from the official docs and nothing worked.

I have tried uninstall react hook from and reinstalling it, also attempted to delete package-lock.json and node_modules

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel


export default function Home() {

  const {

    register,

    formState: { errors },

  } = useForm<FormData>({

    resolver: zodResolver(UserSchema), // Apply the zodResolver

  });

  return (

      <form onSubmit={() => {}}>

        <div className="grid col-auto">

          <FormField

            type="email"

            placeholder="Email"

            name="email"

            register={register}

            error={errors.email}

          />

          <button type="submit">

            Submit email

          </button>

        </div>

      </form>

  );

};


>Solution :

Add "use client" at the very top of your component.

"use client"

export default function Home() {

  const {

    register,

    formState: { errors },

  } = useForm<FormData>({

    resolver: zodResolver(UserSchema), // Apply the zodResolver

  });

  return (

      <form onSubmit={() => {}}>

        <div className="grid col-auto">

          <FormField

            type="email"

            placeholder="Email"

            name="email"

            register={register}

            error={errors.email}

          />

          <button type="submit">

            Submit email

          </button>

        </div>

      </form>

  );

};

``
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading