title: Integrating two react functions in a synchronous way
body: <p>I have the React code below. I want integrate the handleUpdate into the handleUpload function in a synchronous way so that the state is set before the rest of the function is executed. I tried, the following below, with my edit in bold, but it appears to be executing asynchronously and not setting state before executing. Can anybody please instruct me where i need to make a change to meet my needs?</p>
  
  <pre><code>handleUpdate = event =&gt; {
     this.setState({
       selectedFile: event.target.files[0]
     })
  }
  
  handleUpload = () =&gt; {
    **this.handleFileChange;**
    var fd = new FormData();
    fd.append('file', this.state.selectedFile, this.state.selectedFile.name);
    fetch('/upload', {method: 'POST', body: fd})
        .then(response =&gt; {
            return response.json()})
        .then(result =&gt; {
             console.log(result)})
        .catch(function(error) {           
            console.log("ERROR:" + error);
        });
  }
  </code></pre>