title: Can't call setState (or forceUpdate) on an unmounted component
body: <p>I'm trying to fetch the data from the server after component has been updated but I couldn't manage to do that. As far as I understand <code>componentWillUnmount</code> is called when component is about to be destroyed, but I never need to destroy it so it's useless to me. What would be solution for this? When I should set the state?</p>
  
  <pre><code>async componentDidUpdate(prevProps, prevState) {
    if (this.props.subject.length &amp;&amp; prevProps.subject !== this.props.subject) {
      let result = await this.getGrades({
        student: this.props.id,
        subject: this.props.subject
      });
      this.setState({
        subject: this.props.subject,
        grades: result
      });
    }
  }
  
  async getGrades(params) {
    let response, body;
  
    if (params['subject'].length) {
      response = await fetch(apiRequestString.gradesBySubject(params));
      body = await response.json();
    } else {
      response = await fetch(apiRequestString.grades(params));
      body = await response.json();
    }
  
    if (response.status !== 200) throw Error(body.message);
  
    return body;
  }
  </code></pre>
  
  <p>Full error:</p>
  
  <pre><code>Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, 
  but it indicates a memory leak in your application. To fix, cancel all subscriptions and
  asynchronous tasks in the componentWillUnmount method.
  </code></pre>