相关疑难解决方法(0)

获取未捕获的类型错误:path.split 不是反应中的函数

我正在尝试对我的表单进行验证以做出反应。我选择了“react-hook-form”库。但我不断收到错误“Path.split 不是函数。即使在使用他们网站上给出的默认示例后,我也遇到了同样的错误。这是官方网站中给出的默认代码。

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

export default function App() {
  const { register, handleSubmit, watch, errors } = useForm();
  const onSubmit = data => console.log(data);

  console.log(watch("example")); // watch input value by passing the name of it

  return (
    {/* "handleSubmit" will validate your inputs before invoking "onSubmit" */}
    <form onSubmit={handleSubmit(onSubmit)}>
    {/* register your input into the hook by invoking the "register" function */}
      <input name="example" defaultValue="test" ref={register} />
      
      {/* include validation with required …
Run Code Online (Sandbox Code Playgroud)

react-hook-form

38
推荐指数
3
解决办法
2万
查看次数

标签 统计

react-hook-form ×1