title: Any way to bind react variables between functions?
body: <p>I want to avoid typing the same lines of code. Currently, I have an app that is supposed to make an API call, like so. </p>
  
  <pre><code>render: function(){
    var processappkey = localStorage.getItem('yourid');
    var weather = new XMLHttpRequest();
    var deesfault = "Houston, Texas";
    weather.open("GET", "http://apidatafromsomewebsiteq="+deesfault+"&amp;units=imperial&amp;appid="+processappkey, false);
    weather.send(null);   
    var r = JSON.parse(weather.response);
    var check = r.main.temp;
    var theunicorn = r.weather[0].icon;
  
    return (&lt;p&gt;{theunicorn}&lt;/p&gt;)
  }
  </code></pre>
  
  <p>I would like to split this up to something like this:</p>
  
  <pre><code>somecontainer: function(){
    var processappkey = localStorage.getItem('yourid');
    var weather = new XMLHttpRequest();
    var deesfault = "Houston, Texas";
    weather.open("GET", "http://apidatafromsomewebsiteq="+deesfault+"&amp;units=imperial&amp;appid="+processappkey, false);
    weather.send(null);   
    var r = JSON.parse(weather.response);
    var check = r.main.temp;
    var theunicorn = r.weather[0].icon;
  },
  
  render: function() {
     {this.somecontainer()}
  
     return (
       &lt;p&gt;{theunicorn}&lt;/p&gt;
     )
  }
  </code></pre>
  
  <p>I will be calling the API from different areas in my app. Not to mention including a setInverval, which will have me repeating the code again. </p>
  
  <p>As a matter of fact, while I am at it I would also like to know how to go about something like this.</p>
  
  <pre><code>render: function() {
    this.somecontainer();
    setInterval(function() {
      this.somecontainer();
    }, 5000);
  }
  </code></pre>
  
  <p>However, that is a different question, and I'll be happy for insight on the first issue.  </p>