MyForm.js
import React from 'react';
import { withFormik } from 'formik';

const MyForm = () => {
  // The formik variable has all form helper functions
  const formik = useFormik({
    initialValues: {
      name: ''
    },
    validate: values => {
      const errors = {};
      if (!values.name) {
        errors.name = 'Required';
      }
      return errors;
    },
    onSubmit: values => {
      console.log('Will submit', values)
    }
  });
};

export default MyForm;