2

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>;
  }
}
2
  • Any Luck with this issue. I am facing the same on ios Commented Mar 24, 2022 at 11:48
  • Are you using expo development build or bare workflow? If yes, try to build your app again with expo-sqlite library. It seems like your development build does not contain the expo-sqlite library. Try to build it again. more here: docs.expo.dev/development/build Commented Oct 10, 2022 at 11:41

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.