[英]Property 'errors' does not exist on type 'UseFormReturn' in react-hook-form
當我使用 react-hook-form 時,我無法從 react-hook-form 解構錯誤對象。
const { register, handleSubmit, reset, setValue, getValues, errors, formState } = useForm({
resolver: yupResolver(validationSchema)
});
我在官方文檔中找到了答案。 IE
const { register, handleSubmit, reset, setValue, getValues, setError, formState: { errors }, formState } = useForm({
resolver: yupResolver(validationSchema)
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.