title: Use useRef to call submitForm from a parent component
body: <p>I am using react hooks and useRef to call a child method from the parent (see here: <a href="https://stackoverflow.com/questions/37949981/call-child-method-from-parent">Call child method from parent</a>)</p>
  
  <p>Specifically, I am trying to call the formik submitForm method which is located in my child component from my parent component. I know there are other ways to do this (<a href="https://stackoverflow.com/questions/49525057/react-formik-use-submitform-outside-formik">React Formik use submitForm outside &lt;Formik /&gt;</a>) but i would really like to use useRef. </p>
  
  <pre><code>const Auth1 = forwardRef((props, ref) =&gt; {
  
    useImperativeHandle(ref, () =&gt; ({
      handleSubmit() {
        ///////////formik submitForm function goes here
      }
    }));
  
    return(
      &lt;div&gt;
        &lt;Formik
            initialValues={props.initValues}
            validationSchema={Yup.object().shape({
              name: Yup.string().required('Required'),
            })}
            onSubmit={(values, actions) =&gt; {
              console.log(values)
            }}
            render={({ values }) =&gt; (
              &lt;Form&gt;
                  &lt;Field
                    name="name"
                    value={values.name}
                    component={TextField}
                    variant="outlined"
                    fullWidth
                  /&gt;
              &lt;/Form&gt;
            )}
          /&gt;
      &lt;/div&gt;
    )
  
  })
  </code></pre>
  
  <p>There must be a way to bind the submitForm function out of the  component and into the body of my Auth1 component, but imnot quite too sure how.</p>
  
  <p>Any help is greatlly appreciated, thanks!</p>