title: How to run setSubmitting() outside the submit handler?
body: <p>I'm trying to implement the approach described on  <a href="https://www.youtube.com/watch?v=5gl3cCB_26M" rel="noreferrer">https://www.youtube.com/watch?v=5gl3cCB_26M</a>, where all Redux actions are just plain objects (as they were meant to be) and API calls are done by middlewares.</p>
  
  <p>By doing this, the dispatched actions are no longer thunks and can't return a <code>Promise</code>. So I won't be able to use Formik's <code>setSubmitting</code> (to set the <code>isSubmitting</code> flag to <code>false</code>) inside the submit handler, like the code samples on Formik docs and other tutorials I've found.</p>
  
  <p>I've solved the issue in a kinda ugly way, saving a reference of <code>setSubmitting</code> to run it later, inside <code>componentDidUpdate</code>:</p>
  
  <pre><code>import React, { Component } from 'react'
  import { Redirect } from 'react-router-dom'
  
  import LoginForm from 'path/to/LoginForm'
  import validationSchema from 'path/to/LoginForm/validationSchema'
  
  import { login } from 'path/to/actionCreators'
  
  const initialValues = {
    email: '',
    password: '',
  }
  
  class LoginPage extends Component {
    componentDidUpdate() {
      const { auth } = this.props
  
      if (!auth.isProcessing &amp;&amp; this.setSubmitting) {
        this.setSubmitting(false)
      }
    }
  
    onSubmit = (values, { setSubmitting }) =&gt; {
      const { dispatch } = this.props
  
      dispatch(login(values)))
      this.setSubmitting = setSubmitting
    }
  
    render() {
      const { auth } = this.props
      if (auth.user.uid) {
        return &lt;Redirect push to="/" /&gt;
      }
  
      return (
        &lt;div className="login-panel"&gt;
          &lt;h1&gt;Login&lt;/h1&gt;
  
          &lt;Formik
            initialValues={initialValues}
            onSubmit={this.onSubmit}
            render={LoginForm}
            validationSchema={validationSchema}
          /&gt;
        &lt;/div&gt;
      )
    }
  }
  
  const mapStateToProps = state =&gt; ({
    auth: state.auth,
  })
  
  export default connect(mapStateToProps)(LoginPage)
  </code></pre>
  
  <p>How can I do it in a more "elegant" way ?</p>