title: React detect if data from fetched json file is changed wit previous data
body: <p>I'm building a cryptocoin app with React and a JSON API for the latest data. I'm using fetch to load the JSON API and I use setInterval to rerender the app every 10 seconds. </p>
  
  <p>Is there a way to compare the previous data with the new data?</p>
  
  <p>For example, if a value is 3456 and the new value is 3458 I want to compare the old data with the new data and use an arrow up icon or so or give the value a green color. if the new data is 3454 a red color. I can do this with CSS of course. The thing I can't is to compare the difference between the old data and the new data.</p>
  
  <p>my code so far:</p>
  
  <pre><code>GetCryptoData() {
      let dataURL = this.props.coinUrl;
      fetch(dataURL)
          .then(res =&gt; res.json())
          .then(res =&gt; {
          this.setState({
              item: res
          })
      })
  
      componentDidMount(nextState) {
          this.GetCryptoData();
          setInterval(this.GetCryptoData.bind(this), 10000);
      };
  }
  </code></pre>