title: ReactJS - How to detect when cancel is clicked on file input?
body: <p>I want an event or get notified when the user clicks on the <em>cross icon</em> or the <em>cancel button</em> on the fileInput dialog so that I can perform some task based on this.</p>
  
  <p>The <strong>onChange</strong> event is only triggered when the user clicks on <em>Open</em> Button.</p>
  
  <p>Is there a way to get notified when the user clicks on a <em>cross icon</em> or <em>cancel button</em> using ReactJS?</p>
  
  <p><a href="https://i.stack.imgur.com/WiDAS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WiDAS.png" alt="enter image description here"></a></p>
  
  <p>Below is the working code snippet.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class Test extends React.Component {
    constructor() {
      super();
      this.fileInputClicked = this.fileInputClicked.bind(this);
    }
    
    fileInputClicked(event){
      let file = event.target.files[0];
      console.log("File is Selected", file);
    }
  
    render() {
      return (
        &lt;div&gt;
          &lt;div&gt;
            &lt;p&gt;Hello world&lt;/p&gt;
              &lt;input type="file" onChange={this.fileInputClicked}/&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      );
    }
  }
  
  ReactDOM.render(&lt;Test/&gt;, document.getElementById('app'))</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"&gt;&lt;/script&gt;
  
  &lt;div id='app' /&gt;</code></pre>
  </div>
  </div>
  </p>