Skip to content

cannot open database on react-native-windows: Cannot read properties of undefined (reading 'open') #487

@aalbaharnah

Description

@aalbaharnah

There seems to be an issue that prevents sqlite databse from opening when calling SQLite.openDatabase on windows platform
here's the code

import * as React from 'react';
import SQLite from 'react-native-sqlite-storage';

export default function useSqlit() {
    const [isOpen, setIsOpen] = React.useState(false)
    React.useEffect(() => {
        try {
            SQLite.openDatabase({ name: "my.db", location: "default" },
                () => {
                    setIsOpen(true);
                }, () => {
                    // database did not open
                });
        } catch (error) {
            console.log("err: ", error.message)
        }
    });

    return isOpen;
}

Expected Behavior

calling SQLite.openDatabase should open database without errors, so that sql transactions can be executed

Current Behavior

calling SQLite.openDatabase would throw an error that says Cannot read properties of undefined (reading 'open')

Your Environment

"react": "17.0.1",
"react-native": "0.64.2",
"react-native-windows": "^0.64.14",
"react-native-sqlite-storage": "^5.0.0",

Debug logs

Cannot read properties of undefined (reading 'open')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions