title: How to pop results from sqlite in Array in react-native?
body: <p>I am a completely newbie in react native and i am trying to learn it. I want to get results from SQLite and pop them in the array which i could then use in Flat list to display .. Here is my Code: </p>
  
  <pre><code>    //imports
  
  import React,{Component} from 'react';
  import {View,Text,FlatList} from 'react-native';
  
  
  
  //create component
  
  var SQLite = require('react-native-sqlite-storage')
  var db=SQLite.openDatabase({name: 'test.db', createFromLocation: '~sqliteexample.db'})
  
  class DbTask extends Component {
  
  
      constructor(props){
          super(props)
  
          this.state={
              data: []
  
          };
  
          db.transaction((tx)=&gt;{
  
              tx.executeSql('Select * from `pet`',[],(tx,results)=&gt;{
  
                 var len=results.rows.length;
                  for(let i=0; i&lt;len; i++){
                   var row=results.rows.item(i);
                   this.state.data.push(row.owner);
  
                   }
  
  
              });
  
          });
  
      };
  
  
      render(){
  
          return(
          &lt;View&gt;
  
             &lt;FlatList data={this.state.data} 
             renderItems={
              ({item})=&gt; &lt;Text&gt;{item.owner}&lt;/Text&gt;
  
             }
             &gt; &lt;/FlatList&gt;
          &lt;/View&gt;
          );
  
       }
  
  }
  
  
  export default DbTask;
  </code></pre>
  
  <p>I tried to add some alerts in For loop and it showed me correct names of the owners . But i don't get it , either i am not able to push them in the "data" array or my Flat list isn't working. </p>
  
  <p>Any help would be appreciated. Thanks in advance. 
  Regards.</p>