title: Executing a function from another JS file within a react component
body: <p>I want to have a react element on click execute another function from another js file which involves GET requests. How would I go about doing that.</p>
  
  <p>React code: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/** @jsx React.DOM */
  
  var SearchExample = React.createClass({
  
      getInitialState: function(){
          return { searchString: ' ' };
      },
  
      handleClick: function(event){
          // do stuff in another file
      },
  
      handleChange: function(e){
  
          this.setState({searchString:e.target.value});
      },
  
      render: function() {
  
          var libraries = this.props.items,
              searchString = this.state.searchString.trim().toLowerCase();
  
  
          if(searchString.length &gt; 0){
  
              // We are searching. Filter the results.
  
              libraries = libraries.filter(function(l){
                  return l.name.toLowerCase().match( searchString );
              });
  
          }
          else
          {
              libraries = libraries.filter(function(l){
                  return l.popular.toLowerCase().match('true');
              });
          }
  
  
          return &lt;div&gt;
                      &lt;input type="text" value={this.state.searchString} onChange={this.handleChange} placeholder="What are you interested in..." /&gt;
  
                      &lt;ul onClick={this.handleClick}&gt; 
  
                          { libraries.map(function(l){
                              return &lt;li key={l.name}&gt;{l.name} &lt;/li&gt;
                          })}
  
                      &lt;/ul&gt;
  
                  &lt;/div&gt;;
  
      }
  });
  
                                                                                                                                                               
  var libraries = [
  
      { name: 'Technology', popular: 'true'},
      { name: 'Fishing', popular: 'true'},
      { name: 'School',  popular: 'true'},
      { name: 'Camping',  popular: 'true'},
  
  
  ];
  
  // Render the SearchExample component on the page
  
  React.render(
      &lt;SearchExample items={ libraries } /&gt;,
      document.getElementById('sidebar')
  );</code></pre>
  </div>
  </div>
  </p>
  
  <p>Currently the other JS code is in an html file, but I can change that later.</p>