title: How to Formik setFieldValue in useEffect hook
body: <p>I have a Formik form that needs to dynamically change based on information passed via the router. I need to run a graphQL query to retrieve some data and populate the form with that retrieved data. I am able to set up the form and retrieve the data but I can't figure out how to setFieldValue for the underlying form while in a useEffect hook. I feel like I'm missing some important piece to get access to the Formik context but I haven't been able to figure it from the docs.</p>
  
  <p>Any help would be great.</p>
  
  <pre><code>import React, { useState, useEffect } from "react";
  import Router, { useRouter } from "next/router";
  
  import Container from "react-bootstrap/Container";
  import { Field, Form, FormikProps, Formik } from "formik";
  import * as Yup from "yup";
  
  import { useLazyQuery } from "@apollo/react-hooks";
  import { GET_PLATFORM } from "../graphql/platforms";
  
  export default function platformsForm(props) {
    const router = useRouter();
  
    // grab the action requested by caller and the item to be updated (if applicable)
    const [formAction, setFormAction] = useState(router.query.action);
    const [formUpdateId, setFormUpdateId] = useState(router.query.id);
  
    const [initialValues, setInitialValues] = useState({
      platformName: "",
      platformCategory: ""
    });
  
    const validSchema = Yup.object({
      platformName: Yup.string().required("Name is required"),
      platformCategory: Yup.string().required("Category is required")
    });
  
    const [
      getPlatformQuery,
      { loading, error, data: dataGet, refetch, called }
    ] = useLazyQuery(GET_PLATFORM, {
      variables: { id: formUpdateId }
    });
  
    useEffect(() =&gt; {
      !called &amp;&amp; getPlatformQuery({ variables: { id: formUpdateId } });
      if (dataGet &amp;&amp; dataGet.Platform.platformName) {
        console.log(
          dataGet.Platform.platformName,
          dataGet.Platform.platformCategory
        );
  
        //
        // vvv How do I set Field values at this point if I don't have Formik context
        // setFieldValue();
        //
      }
    }),
      [];
  
    const onSubmit = async (values, { setSubmitting, resetForm }) =&gt; {
      console.log("submitted");
      resetForm();
      setSubmitting(false);
    };
  
    return (
      &lt;Container&gt;
        &lt;Formik
          initialValues={initialValues}
          validationSchema={validSchema}
          onSubmit={onSubmit}
        &gt;
          {({
            handleSubmit,
            handleChange,
            handleBlur,
            handleReset,
            values,
            touched,
            isInvalid,
            isSubmitting,
            isValidating,
            submitCount,
            errors
          }) =&gt; (
            &lt;Form&gt;
              &lt;label htmlFor="platformName"&gt;Name&lt;/label&gt;
              &lt;Field name="platformName" type="text" /&gt;
  
              &lt;label htmlFor="platformCategory"&gt;Category&lt;/label&gt;
              &lt;Field name="platformCategory" type="text" /&gt;
  
              &lt;button type="submit"&gt;Submit&lt;/button&gt;
            &lt;/Form&gt;
          )}
        &lt;/Formik&gt;
      &lt;/Container&gt;
    );
  }
  
  </code></pre>