title: How to perform debounce?
body: <p>How do you perform debounce in React.js?</p>
  
  <p>I want to debounce the handleOnChange.</p>
  
  <p>I tried with <code>debounce(this.handleOnChange, 200)</code> but it doesn't work.</p>
  
  <pre><code>function debounce(fn, delay) {
    var timer = null;
    return function() {
      var context = this,
        args = arguments;
      clearTimeout(timer);
      timer = setTimeout(function() {
        fn.apply(context, args);
      }, delay);
    };
  }
  
  var SearchBox = React.createClass({
    render: function() {
      return &lt;input type="search" name="p" onChange={this.handleOnChange} /&gt;;
    },
  
    handleOnChange: function(event) {
      // make ajax call
    }
  });
  </code></pre>