【问题标题】:TypeError: path.split is not a function in React-hook-formTypeError: path.split 不是 React-hook-form 中的函数
【发布时间】:2021-04-09 21:48:24
【问题描述】:

不知道出了什么问题,谁能解释一下,我根据文档写了寄存器,但它仍然给出 -

请帮忙

【问题讨论】:

  • 我承认我没有使用 react-hook-form,但似乎您将一个裸函数作为未命名的道具传递给该输入。 register 的块应该是什么?
  • 当您在get.ts 中执行console.log(typeof path) 时会显示什么?您也可以尝试console.dir(path) 获取更多信息。

标签: javascript reactjs react-hooks react-hook-form


【解决方案1】:

您使用的 React Hook Form v7 语法错误,这是一个有效的示例:

字段名作为寄存器的第一个参数传递

<input
  type="text"
  {...register("FIELD_NAME", { required: required, validate: validation })}
/>

React Hook Form V7 - Register API Documentation

React Hook Form V6 - Register API Documentation

【讨论】:

    猜你喜欢
    • 2022-08-07
    • 2021-10-30
    • 2017-04-10
    • 2021-11-27
    • 1970-01-01
    • 2023-02-19
    • 1970-01-01
    • 2020-08-26
    • 2021-07-16
    相关资源
    最近更新 更多