Skip to content

React Native - Get all results from database with SQLite and pass it to flatlist #22767

Closed

Description

@reactnativesucks

I am using this library: https://github.com/andpor/react-native-sqlite-storage in my project.

I retrieve single row from database like this:

constructor(props){

super(props)

this.state={
    data: []
};
db.transaction((tx) => {
  tx.executeSql('SELECT * FROM table_worker', [], (tx, results) => {
      console.log("Query completed");

    var len = results.rows.length;
    for (let i = 0; i < len; i++) {
      let row = results.rows.item(i);
      this.setState({worker_fname: row.worker_fname});
      this.setState({worker_sname: row.worker_sname});
      this.setState({worker_lname: row.worker_lname});
    }
  });
});

};

render() {
return (
  <View>
    <View>
      <Text>{this.state.worker_fname}</Text>
      <Text>{this.state.worker_sname}</Text>
      <Text>{this.state.worker_lname}</Text>
    </View>
  </View>
);
}

But now i want to fetch all data from database, and pass it to flatlist.

Activity

  1. react-native-bot commented on Dec 23, 2018

    @react-native-bot
    Collaborator

    We are automatically closing this issue because it does not appear to follow any of the provided issue templates.

    Please make use of the bug report template to let us know about a reproducible bug or regression in the core React Native library.

    If you'd like to propose a change or discuss a feature request, there is a repository dedicated to Discussions and Proposals you may use for this purpose.

  2. locked as resolved and limited conversation to collaborators on Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: FlatListRan CommandsOne of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.Type: QuestionIssues that are actually questions and not bug reports.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions