Uncaught TypeError: (intermediate value)(...) is not a function [Yup, formik]
Asked Answered
C

2

5
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

Candelabra answered 5/12, 2022 at 21:15 Comment(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.Alcoran
G
10

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

validationSchema: yup.object(formSchema)

Grassland answered 22/4, 2023 at 21:52 Comment(1)
This worked for me. This should be marked as the correct answer.Alcala
P
8

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),
  })
Preter answered 23/3, 2023 at 5:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.