DEV Community

Build and validate forms in React Native using Formik and Yup

Aman Mittal on September 17, 2019

Formik and yup are great development tools to build awesome looking UI forms as per your React Native application needs. You will get the full co...
Collapse
 
kevinleung56 profile image
Kevin Leung

This helped a lot but I keep getting 'Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.' error. Any ideas on this?

Collapse
 
amanhimself profile image
Aman Mittal

The general occurrence of that error is when one of the component file is missing export default statement.

Collapse
 
kevinleung56 profile image
Kevin Leung • Edited

Got it fixed. Was somehow due to the use of Fragment in the formik. Changed it to View or SafeAreaView and it worked.

Thread Thread
 
amanhimself profile image
Aman Mittal

I am glad it worked for you :)

Collapse
 
hggonzalezdev profile image
Gabriel Gonzalez

Great post, it help me a lot.

How will you use the code written in here with redux, I did some research I found the withFormik property but is not working well with the handleChangText, it recognize the email as being an undefined value.

Any work around you know about?

Collapse
 
cabhara profile image
Christina Bharara

didn't work for me.. getting error "check the render method of Formik".

Collapse
 
amanhimself profile image
Aman Mittal

Are you using the same version of Formik dep as the demo in Github repo? Maybe this could be because Formik 2.0 was recently released.

Collapse
 
cabhara profile image
Christina Bharara

yes using Formik 2.1.2. I got it to work. Had to change Fragment to React.Fragment, Yup to yup in the code, and one comma is missing in your code example. Thanks!

Thread Thread
 
amanhimself profile image
Aman Mittal

I am glad it worked out for you. I am sorry for the missing comma, will fix that.

Collapse
 
davidrivaldy profile image
David Rivaldy

Anybody have an idea to submit with Formik after confirmation dialog modal? (With Material-UI Dialog). So submit will trigger inside the dialog component.

Collapse
 
uguremirmustafa profile image
uguremirmustafa

Have you find any useful solution you can share?

Collapse
 
ahmedshakeel083 profile image
ahmedshakeel083

i am stuck with Autocomplete and formik stack with no error shown when the filled is skipped , any idea how to sort this out