skip to Main Content

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


  1. 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 transactions withTransactionAsync

    Login or Signup to reply.
  2. Yes, a few weeks ago expo sqlite completely changed. To use the older version just import:
    import * as SQLite from ‘expo-sqlite/legacy’;

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search