Hello, i am newbie in expo react native. I have a code working good, using a sqlite database.
The code to read data is:
db.transaction((tx) => {
tx.executeSql(query, , (tx, results) => {
if(results.rows.length == 0){
this.alertEmpty();
}
this.setState({
data: results.rows._array
});
});
});
}
My question is: how i can display using console.log the values inside “data”
Thanks.
The second parameter to setState() is an optional callback function that will be executed once setState is completed and the component is re-rendered. Generally we recommend using componentDidUpdate() for such logic instead.
Hello,
Few days ago I try console.log(results.rows._array); but i got “undefined” in console output.
Same with:
this.setState(
prevState => {
data: results.rows._array;
},
() => console.log(this.state.data)
);