title: Auto update the user interface in ReactJS
body: <p>I am new to react and not sure whether this question should be asked or not. Have searched many blogs but could not come to a conclusion. I have a rest API which is updating data continuously at server side, take for example stock data API. Now, if I use <code>$.get</code> of jquery or <code>fetch()</code> from react library it will update data only on initial page load. What I am looking for is as data change occurs from the API end simultaneously the change should be reflected in the user interface. Any help will be appreciated. 
  As discussed with @Shubham Khatri please find te code below for react.</p>
  
  <pre><code>var StockData = React.createClass({
        getInitialState: function() {
          return {
              stock: []
          };
        },
  
        componentDidMount: function() {
          this.serverRequest = $.get(this.props.source, function (data) {     
             console.log(" Data value :"+data);
             var old = data.replace("//", "");   
             this.setState({   
                      stock: JSON.parse(old)   
                 });
  
          }.bind(this));
          console.log(" Data value after bind  :"+this.state.stock);
        },
  
        componentWillUnmount: function() {
          this.serverRequest.abort();
        },
  
        render: function() {
           console.log(" Stock value :"+this.state.stock);
           return (
                  React.createElement("div",null,
                          React.createElement("ul",null,
                              this.state.stock.map(function (listValue){
                                  return React.createElement("li",null,listValue.t," ( ",listValue.e,"  ) -  "," Current Price :",listValue.l_cur,"    Date : ",listValue.lt
                                  );
                              })
                          )
                      )
                  );
              }
          });
  </code></pre>