formik and yup reactjs

Solutions on MaxInterview for formik and yup reactjs by the best coders in the world

showing results for - "formik and yup reactjs"
Basile
13 Jul 2016
1import React from 'react';
2 import { Formik, Field, Form, ErrorMessage } from 'formik';
3 import * as Yup from 'yup';
4 
5 const SignupForm = () => {
6   return (
7     <Formik
8       initialValues={{ firstName: '', lastName: '', email: '' }}
9       validationSchema={Yup.object({
10         firstName: Yup.string()
11           .max(15, 'Must be 15 characters or less')
12           .required('Required'),
13         lastName: Yup.string()
14           .max(20, 'Must be 20 characters or less')
15           .required('Required'),
16         email: Yup.string().email('Invalid email address').required('Required'),
17       })}
18       onSubmit={(values, { setSubmitting }) => {
19         setTimeout(() => {
20           alert(JSON.stringify(values, null, 2));
21           setSubmitting(false);
22         }, 400);
23       }}
24     >
25       <Form>
26         <label htmlFor="firstName">First Name</label>
27         <Field name="firstName" type="text" />
28         <ErrorMessage name="firstName" />
29         <label htmlFor="lastName">Last Name</label>
30         <Field name="lastName" type="text" />
31         <ErrorMessage name="lastName" />
32         <label htmlFor="email">Email Address</label>
33         <Field name="email" type="email" />
34         <ErrorMessage name="email" />
35         <button type="submit">Submit</button>
36       </Form>
37     </Formik>
38   );
39 };
40
41export default SignupForm;
queries leading to this page
yub reactjs formikformik yup exampleformik and yup in react nativehow to use validation schema in useformikformik and yup with react nativereact form validation with formik and yup formik and yup reactformik with yup react nativeinstall formik and yup in reactreactjs yup without formikreact forms with formik and yupuseformik validation schema with yupyup with formikuseformik hook with yupuse formik with yupreact forms using formik and yupwhat it yup formikusing onchange in react js and yup formikformik with yupformik yup reactreact bootstrap formik yupformik vs yupformik and yup react nativenode react form validation with formik and yupformik example react form with yupformik yup reactjsuseformik validationformik and you with reactformik using yup yup and formikyup 2b formik 2b reactapi formik yup reactjsformik with yup exampleformik and yup in reactvalidationschema yup react classuse validation schema with useformik hookformik yup documentationbest way formik in formik reactformik and yup form validationreact formik with yupformik and yupformik and yup react native exampleformik validation in jsxyup validation schema example not for a formformik and yup reactjsformik and yup validationformik react yup exampleformik place the yep validationschema reusablleyup username validationyup in formikformik yup use component state reactformik 2b react 2b yupyup formikreact formik yupinstall formik and yup reactnodejs react form validation with formik and yupform with formik and yup in reactyup validation with useformikreact formik and yupform validation using formik and yup in reactformik yupformik with yup react jsinstall formik and yup 5bformik yup validationyup with useformikformik and yup reactjs