ive initiated a new react-native app using npx init
where i transferred a code i was using on anothe react native app. this code uses react expo-sqlite
. i installed expo-sqlite but when i run the app, i get this annoying error:
TypeError: undefined is not an object (evaluating 'ExponentSQLite.exec')
ive tried to update expo to latest version but the error still persists. i even deleted node-modules and re-installed using npm istall but it isnt working. how do i fix it? I'm running bare react-native which also uses some expo packages.
this is my code:
import React from "react";
import { Text } from "react-native";
import * as SQLite from "expo-sqlite";
const db = SQLite.openDatabase("silkyMarket.db");
export default class SQLiteScreen extends React.Component {
constructor() {
super();
this.state = {
todo: [],
search: "",
};
}
componentDidMount() {
// create user table if not exist
db.transaction((tx) => {
tx.executeSql(
"create table if not exists tbl_register (id integer primary key not null, name text, contact text);"
);
});
// check if registered
const query = "select *from tbl_register";
const array = [];
db.transaction((tx) => {
tx.executeSql(query, array, (tx, results) => {
this.setState({ todo: results.rows });
console.log(this.state.todo._array);
});
});
}
render() {
return <Text>this is important</Text>;
}
}
If you are using the Expo bare workflow, you must delete the Android folder and run
expo run:android
again.After these steps, the mentioned error stopped for me.