title: How to fix "Can't perform a React state update on an unmounted component." error in React Native
body: <p>I'm fetching data in my local database (sqlite) and updating the state, and this error is appearing: </p>
  
  <blockquote>
    <p>Can't perform a React state update 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.</p>
  </blockquote>
  
  <p>no solution helped me.</p>
  
  <pre><code>
  _isMounted = false;
    constructor(props) {
      super(props);
      this.state = {
        slug: "",
        value: "",
        cod_year: "",
        months: [],
        years: [],
        loadingData: true,
      };
    }
    db = openDatabase({ name: 'test.db', createFromLocation : '~my_finances.db'});
  
    getYears = () =&gt; {
      if(this.state.loadingData){
        this.db.transaction((txn)=&gt;{
          txn.executeSql(
              "SELECT cod, slug FROM year",
              [],
              (tx, res) =&gt; {
                  if(res.rows.length &gt; 0){
                      rows = [];
                      for(let i=0; i&lt;res.rows.length;i++){
                          rows.push(res.rows.item(i));
                      }
                      this.setState({years: rows}, {loadingData: false});
                  }
              }
          )
        })
      }
  
    }
  
    componentDidMount(){
      this._isMounted = true;
      this.getYears();
    }
  
    render() {
      const state = this.state;
      if(!state.loadingData){
        const pickerItens = state.years.map((record, index) =&gt; {
          &lt;Picker.Item label={record.slug} value={record.cod}/&gt;  
        })
        return (
          &lt;View style={{flex: 1}} &gt;
            &lt;ScrollView style={styles.container}&gt;
              &lt;View style={styles.form_add}&gt;
                &lt;Text style={styles.form_slug} &gt; Adicionar &lt;/Text&gt;
                &lt;TextInput 
                    placeholder="Digite o mês..."
                    onChangeText={(slug) =&gt; { this.setState({slug}) }}
                    value={this.state.slug}
                    style={styles.input_add}
                /&gt;
                &lt;TextInput 
                    placeholder="Digite o valor..."
                    onChangeText={(value) =&gt; { this.setState({value}) }}
                    value={this.state.value}
                    style={styles.input_add}
                /&gt;
                &lt;Picker onValueChange = {(cod_year) =&gt; {this.setState({cod_year})}}&gt;
                  { pickerItens }
                &lt;/Picker&gt;
  
                &lt;Button color="#7159C1" title="Salvar" onPress={() =&gt; this.addYear()} /&gt; 
              &lt;/View&gt;
            &lt;/ScrollView&gt;
            &lt;Footer navigate={this.props.navigation.navigate} /&gt;
          &lt;/View&gt;
        );
      }else{
        &lt;Text&gt; Loading... &lt;/Text&gt;
      }
    }
  
  </code></pre>