title: How can I access the 'this' in a read.onloadend in a React component?
body: <p>I'm trying to read a file that the user uploads in a React component and set the state of the React component to the file contents. However, in the <code>read.onloadend</code> callback function, I can't access the state through <code>this</code>.</p>
  
  <p>Here is the actual form part (I am using react-bootstrap) </p>
  
  <pre><code>      &lt;FormGroup&gt;
            &lt;FormControl
              id="fileUpload"
              type="file"
              accept=".txt"
              onChange={this.handleSubmit.bind(this)}
            /&gt;
        &lt;/FormGroup&gt;
  </code></pre>
  
  <p>And here is my function to handle submit:</p>
  
  <pre><code>  handleSubmit(e) {
      e.preventDefault()
      let inputtext;
      let file = e.target.files[0];
      let read = new FileReader();
      read.readAsBinaryString(file);
      read.onloadend = function(){
        this.setState({filetext : read.result});
      }
      read.onloadend.bind(this);
    }
  </code></pre>