title: React axios post request and setState on props change
body: <p>I have a react app and I am using <strong>geolocated</strong> to get users location.</p>
  
  <p>Following the instructions for the initialization I have wrapped the component:</p>
  
  <pre><code>export default geolocated({
      positionOptions: {
          enableHighAccuracy: true,
      },
      userDecisionTimeout: 15000,
  })(ShowPois);
  </code></pre>
  
  <p>As soon as the user accepts (allows) the location finding on the browser I want two things to happen.</p>
  
  <p>First I need to set a flag when then location is available to the app, so I have this:</p>
  
  <pre><code>static getDerivedStateFromProps(props, state) {
          if (!state.geolocatedReady &amp;&amp; props.coords) {
              return {
                  geolocatedReady: true
              }
          }
          return null;
      }
  </code></pre>
  
  <p><em>Notice  that props.coords comes from geolocated</em></p>
  
  <p>The second thing is that I want to complete an input box with the address of the location found. In order to do this I have to do a post request to an api to get the address, but the problem is I cannot use the getDerivedStateFromProps() method because the method must return a value, not a promise (made by axios post request). </p>
  
  <p>So how can I make a post request and then set the state when a prop changes in the component?</p>