最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Uncaught TypeError: (intermediate value)(...) is not a function [Yup, formik] - Stack Overflow

programmeradmin1浏览0评论
const {values, handleChange, handleSubmit, errors} = useFormik({
    initialValues: {
      name: '',
      address: '',
      latitude: '',
      longitude: '',
      nit: '',
      category: '',
      email: '',
    },
    validationSchema: {formSchema},
    validateOnChange: false,
    onSubmit: () => console.log(values),
  })

En: The error occurs because we are surrounding the validation schema with keys, we must pass it without keys, keep in mind the validateOnchange.

Es: El error ocurre porque estamos rodeando el esquema de validación con llaves, debemos pasarlo sin llaves, tener presente el validateOnchange

const {values, handleChange, handleSubmit, errors} = useFormik({
    initialValues: {
      name: '',
      address: '',
      latitude: '',
      longitude: '',
      nit: '',
      category: '',
      email: '',
    },
    validationSchema: {formSchema},
    validateOnChange: false,
    onSubmit: () => console.log(values),
  })

En: The error occurs because we are surrounding the validation schema with keys, we must pass it without keys, keep in mind the validateOnchange.

Es: El error ocurre porque estamos rodeando el esquema de validación con llaves, debemos pasarlo sin llaves, tener presente el validateOnchange

Share Improve this question asked Dec 5, 2022 at 21:15 Alexander Rincón S.Alexander Rincón S. 511 silver badge2 bronze badges 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Bot Commented Dec 6, 2022 at 7:57
Add a comment  | 

2 Answers 2

Reset to default 11

If you are using yup, the formSchema must be a yup.object();

validationSchema: yup.object(formSchema)

The problem is your validationSchema: {formSchema} is incorrect. You need to remove the bracket around formSchema.

i.e.

const {values, handleChange, handleSubmit, errors} = useFormik({
    initialValues: {
      name: '',
      address: '',
      latitude: '',
      longitude: '',
      nit: '',
      category: '',
      email: '',
    },
    validationSchema: formSchema, // <--- use this instead of {formSchema}
    validateOnChange: false,
    onSubmit: () => console.log(values),
  })
发布评论

评论列表(0)

  1. 暂无评论