title: Access updated FormikProps after arrayHelper function runs
body: <p>I have the following code:</p>
  
  <pre><code>  addLineItem = (formProps: FormikProps&lt;MyEntity&gt;, arrayHelpers: ArrayHelpers) =&gt; {
      arrayHelpers.push(getNewEntity(formProps.values.date));
      reassignLineItemIds(formProps);
    };
  </code></pre>
  
  <p>The problem I'm experiencing is that <code>reassignLineItemIds</code> needs the updated values in <code>formProps</code> and I don't have access to the updated version of <code>formProps</code> after <code>arrayHelpers.push()</code> has run.</p>
  
  <p>One solution I came across involved creating the following component:</p>
  
  <pre><code>
  interface ConnectedProps {
    delay?: number;
    onChange: (prevProps: FormikProps&lt;MyEntity&gt;, nextProps: FormikProps&lt;MyEntity&gt;) =&gt; void;
  }
  
  interface OwnProps extends ConnectedProps {
    formik: FormikProps&lt;FormikValues&gt;;
  }
  
  class FormChangeHandler extends Component&lt;OwnProps&gt; {
    onChange = debounce(this.props.onChange, this.props.delay || 0);
  
    componentDidUpdate(prevProps: OwnProps) {
      const { formik } = this.props;
      const { isValid } = formik;
  
      const hasChanged = !isEqual(prevProps.formik.values, formik.values);
      const shouldCallback = isValid &amp;&amp; hasChanged;
  
      if (shouldCallback) {
        this.onChange(prevProps.formik as FormikProps&lt;MyEntity&gt;, formik as FormikProps&lt;MyEntity&gt;);
      }
    }
  
    render() {
      return null;
    }
  }
  
  const connected = connect&lt;ConnectedProps&gt;(FormChangeHandler);
  
  export { connected as FormChangeHandler };
  </code></pre>
  
  <p>Then, in my Formik <code>&lt;Form&gt;</code>, include the following:</p>
  
  <pre><code>&lt;FormChangeHandler onChange={
      (prevProps: FormikProps&lt;MyEntity&gt;, nextProps: FormikProps&lt;MyEntity&gt;) =&gt; {
          if (getLineItemCount(prevProps.values) !== getLineItemCount(nextProps.values)) {
          reassignLineItemIds(nextProps);
      }
  }} /&gt;
  </code></pre>
  
  <p>This works, but it will have negative performance impacts and just seems like a crazy hoop to jump through.</p>