我正在使用 Next.js、TypeScript、sanity 和 tailwindcss。我尝试使用react-hook-form,但收到错误。
我试过了:
Post为箭头函数Post为 const 函数IFormInput为类型这是错误所在:
23 | formState: { errors },
> 24 | } = useForm<IFormInput>();
| ^
25 |
26 | return (
27 | <main>
Run Code Online (Sandbox Code Playgroud)
这是我在页面文件夹中的代码([slug].tsx):
import { useForm, SubmitHandler } from "react-hook-form";
interface IFormInput {
_id: string;
name: string;
email: string;
comment: string;
}
function Post({ post }: Props) {
const { register, handleSubmit, formState: { errors } } = useForm<IFormInput>();
return …Run Code Online (Sandbox Code Playgroud)