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 form
and reinstalling it, also attempted to delete package-lock.json
and node_modules
.
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 "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>
);
};