title: React setState gives emty array in an axiosRequest
body: <p>Hi I do have to following simplyfied code. I use Formik as a Validation. Also Material Ui and Reactjs. The Form, Row and Col Tags come from Material. The FastField is same as InputField.</p>
  <p>What I want is onClick in the Inputfield a dropdown appears and shows an array which I fetched with the axios-Request.</p>
  <p>´´´</p>
  <pre><code>const url = 'http://localhost:3000';
  const [searchValues, setSearchValues] = useState([]);
  
  
  const getDropdownItems = (event) =&gt; {
      console.log('event', event.target.getAttribute('id'));
          axios
          .get(`${url}/${event.target.getAttribute('id')}`)
          .then(
              (res) =&gt; setSearchValues(res),
              console.log('restl', searchValues)
          );
  };
          
               render(
                      &lt;Form
                          onFocus={getDropdownItems}
                          onSubmit={formik.handleSubmit}
                           &gt;
                                  &lt;Row&gt;
                                      &lt;Col xs=&quot;auto&quot; style={minWidth}&gt;
                                          &lt;FastField
                                              id=&quot;DatumEingabe&quot;
                                              name=&quot;DatumEingabe&quot;
                                              component={Autocomplete}
                                              label=&quot;Datum-Eingabe&quot;
                                              type=&quot;text&quot;
                                              options={searchValues}
                                          /&gt;
                                      &lt;/Col&gt;
                                  &lt;/Row&gt;
                              &lt;/Form&gt;
                         )
  </code></pre>
  <p>When I check my console I get from the first console.log the name of
  the Inputfield. The second console.log says the array is empty,
  despite the res is available and should be set. Why does it not work
  this way.</p>