Trying to get list from an existed table (Nouns) in prepopulated database of my react native project but it is returning undefined.
I have added the prepopulated database in Android:
for IOS i just created a new assets folder on the root project and added the database file within it
When I run the same query on SQLite browser i get the result in image Sql query results in SQlite browser
Any help would be appreciated
import { useEffect, useState } from 'react'
import SQLite from 'react-native-sqlite-storage';
export const getVerbs = () =>{
const [nouns, setNouns] = useState([]);
const db = SQLite.openDatabase({
name: 'DictionaryG.db',
createFromLocation: 1
})
useEffect(() => {
db.transaction((tx) => {
tx.executeSql('SELECT Definition FROM Nouns limit 1',
[],
(tx, results) => {
var temp = [];
console.log(results)
for (let i = 0; i < results.rows.length; ++i)
temp.push(results.rows.item(i));
setNouns(temp);
});
});
}, [])
return nouns;
}