1 import React from 'react';
2 import { useFormik } from 'formik';
3
4 // Create empty context
5 const FormikContext = React.createContext({});
6
7 // Place all of what’s returned by useFormik into context
8 export const Formik = ({ children, ...props }) => {
9 const formikStateAndHelpers = useFormik(props);
10 return (
11 <FormikContext.Provider value={formikStateAndHelpers}>
12 {typeof children === 'function'
13 ? children(formikStateAndHelpers)
14 : children}
15 </FormikContext.Provider>
16 );
17 };