Код: Выделить всё
"use client";
import React from "react";
import { useForm, SubmitHandler } from "react-hook-form"
import { Inputs } from "@/types/contactinputs";
import toast from "react-hot-toast";
const Contact = () => {
const {
register, handleSubmit, watch, formState: { errors, isSubmitted, isSubmitSuccessful, isSubmitting }, reset,
} = useForm({
defaultValues: {
fullName: "",
email: "",
}
})
const onSubmitfunc: SubmitHandler = async (data) => {
console.log(data);
toast.success("Message 1");
// toast.success("Message 2");
};
// console.log(watch("fullName")) // watch input value by passing the name of it
return (
Send a message
{errors.fullName && < div> *Please enter a valid Full Name}
{errors.email && < div>*Please enter a valid Email}
Send Message
);
};
export default Contact;
Подробнее здесь: https://stackoverflow.com/questions/797 ... st-present