title: How to pass state values to initial values in formik in react js
body: <p>I'm using formik library in my react application. Initially, I declared state values in the constructor, In componentDidMount I'm calling an API with that app response am updating state values, Can anyone help me in passing state values to fomik initial values</p>
  
  <p>In my situation formik taking initial state values which are declared in the constructor.thanks in advance</p>
  
  <pre><code>class Dropdown extends Component {
  
          constructor(props) {
              super(props);
              this.state = {
                //some data
              };
            }
            componentDidMount() {
             //api call
             this.setState( {
                //update state values with api response data
              });  
           }
         render() {
              return (
              &lt;Formik
                initialValues={this.state}
                validate={validate(validationSchema)}
                onSubmit={onSubmit}
                render={
                  ({
                    values,
                    errors,
                    touched,
                    status,
                    dirty,
                    handleChange,
                    handleBlur,
                    handleSubmit,
                    isSubmitting,
                    isValid,
                    handleReset,
                    setTouched
                  }) =&gt; ( 
                   //form uses initialValues
                )} /&gt;
                )
              }
      }
  </code></pre>