I have been running into this issue for weeks. I have installed expo-sqlite
into my React Native app, but can not use it without constantly running into blockers. Currently it believes that I cannot use either of these methods despite declaring on line 1 import * as SQLite from "expo-sqlite";
db.transaction
as Property 'transaction' does not exist on type 'SQLiteDatabase'
db = SQLite.openDatabase("tasks.db")
as Property 'openDatabase' does not exist on type ...node_modules/expo-sqlite/build/index")'. Did you mean 'openDatabaseSync'?
I think I can get around the issue of the .openDatabase by using a constructor as below, but it still prevents me from calling db.transaction
:
db;
constructor(db: SQLite.SQLiteDatabase) {
this.db = db;
}
I am running "expo": "^51.0.0"
and "expo-sqlite": "~14.0.3"
I have tried using both newer and older versions of expo-sqlite
in my project, but no luck.
2
Answers
I think you have to check the new documentation for expo-sqlite, they change all the method and structure: docs.expo.dev/versions/latest/sdk/sqlite
As the error says you have to use
openDatabaseSync
and for the transactionswithTransactionAsync
Yes, a few weeks ago expo sqlite completely changed. To use the older version just import:
import * as SQLite from ‘expo-sqlite/legacy’;