title: Can't call setState function in onSubmit of Formik
body: <p>I'm trying to add an alert every time I submit my form. I tried to pass my state as a prop to my component but that doesn't seem to work.</p>
  
  <p>Here is my class state:</p>
  
  <pre><code>this.state = {
            alert_variant: '',
            alert_heading: '',
            alert_body: '',
            alert_show: false
  };
  </code></pre>
  
  <p>Here is how I render my Alert:</p>
  
  <pre><code>&lt;ReactAlert 
    show={this.state.alert_show}
    variant={this.state.alert_variant} 
    heading={this.state.alert_heading} 
    body={this.state.alert_body} 
  /&gt;
  </code></pre>
  
  <p>Here is a portion of my submit handler in Formik which sends the values to API:</p>
  
  <pre><code>onSubmit={(
            values, 
            {
             setSubmitting, 
             resetForm
            }) =&gt;{
                  fetch("url.com", {
                          method: 'POST',
                          mode: 'cors',
                          body: JSON.stringify(values, null, 2)
                      }
                  )
  .then(res =&gt; res.json())
  .then(
  (result) =&gt; {
         console.log(result)
         setSubmitting(false)
         resetForm(values)
         this.setState({
                 alert_show: true,
                 alert_variant: 'success',
                 alert_heading: 'Sample Header',
                 alert_body: 'Sample body.'
         });
  },
      (error, result) =&gt; {
                          this.setState({
                              error
                          });
                          console.log(this.state.error);
                          setSubmitting(false);
                      }
                  )
  </code></pre>
  
  <p>And here is my Alert component:</p>
  
  <pre><code>function ReactAlert(props){
      const [show, setShow] = useState(false);
      if (show) {
          return(
              &lt;Bs.Alert variant={props.variant} onClose={() =&gt; setShow(false)} dismissible&gt;
                  &lt;Bs.Alert.Heading&gt;{props.heading}&lt;/Bs.Alert.Heading&gt;
                  &lt;p&gt;
                      {props.body}
                  &lt;/p&gt;
              &lt;/Bs.Alert&gt;
          );
      }
      return null;
  }
  </code></pre>
  
  <p>Now how can I change my state variable within the submit handler of Formik? Is that even possible? I tried to create a separate submit handler function but that didn't work either.</p>