title: How to cancel a fetch on componentWillUnmount
body: <p>I think the title says it all. The yellow warning is displayed every time I unmount a component that is still fetching.</p>
  
  Console
  
  <blockquote>
    <p>Warning: Can't call <code>setState</code> (or <code>forceUpdate</code>) on an unmounted component. This is a no-op, but ... To fix, cancel all subscriptions and asynchronous tasks in the <code>componentWillUnmount</code> method.</p>
  </blockquote>
  
  <pre><code>  constructor(props){
      super(props);
      this.state = {
        isLoading: true,
        dataSource: [{
          name: 'loading...',
          id: 'loading',
        }]
      }
    }
  
    componentDidMount(){
      return fetch('LINK HERE')
        .then((response) =&gt; response.json())
        .then((responseJson) =&gt; {
          this.setState({
            isLoading: false,
            dataSource: responseJson,
          }, function(){
          });
        })
        .catch((error) =&gt;{
          console.error(error);
        });
    }
  </code></pre>