【问题标题】:Property 'errors' does not exist on type 'UseFormReturn' in react-hook-formreact-hook-form 中的“UseFormReturn”类型不存在属性“错误”
【发布时间】:2021-11-06 13:17:44
【问题描述】:

当我使用 react-hook-form 时,我无法从 react-hook-form 中解构错误对象。

 const { register, handleSubmit, reset, setValue, getValues, errors, formState } = useForm({
        resolver: yupResolver(validationSchema)
    });

【问题讨论】:

    标签: reactjs react-hook-form


    【解决方案1】:

    我在官方文档中找到了答案。即

     const { register, handleSubmit, reset, setValue, getValues, setError, formState: { errors }, formState } = useForm({
        resolver: yupResolver(validationSchema)
      });
    

    【讨论】:

      猜你喜欢
      • 2021-06-17
      • 1970-01-01
      • 2021-11-15
      • 2020-12-09
      • 2022-01-23
      • 1970-01-01
      • 2020-05-21
      • 2021-04-10
      • 1970-01-01
      相关资源
      最近更新 更多