All the formik boilerplate stuff example
1import React, { useRef } from 'react';
2import { useFormik } from 'formik';
3import ReCAPTCHA from 'react-google-recaptcha';
4import * as Yup from 'yup';
5
6const TEST_SITE_KEY = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI';
7
8const ContactForm = () => {
9 const reCaptchaRef = useRef(null);
10
11 // const validate = (values) => {
12 // const errors = {};
13 // if (!values.firstName) {
14 // errors.firstName = 'Required';
15 // } else if (values.firstName.length > 15 || values.firstName.length < 2) {
16 // errors.firstName = 'Must be between 2 and 15 characters';
17 // }
18
19 // if (!values.lastName) {
20 // errors.lastName = 'Required';
21 // } else if (values.lastName.length > 20) {
22 // errors.lastName = 'Must be 20 characters or less';
23 // }
24
25 // if (!values.email) {
26 // errors.email = 'Required';
27 // } else if (!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$/i.test(values.email)) {
28 // errors.email = 'Invalid email address';
29 // }
30
31 // if (!values.recaptcha) {
32 // errors.recaptcha = 'Prove You Are Not A Robot';
33 // }
34
35 // return errors;
36 // };
37