import { openDatabase } from 'react-native-sqlite-storage'
const db = openDatabase({ name: `${dbName}.db` })
Cannot read properties of undefined (reading 'open')
The SQLitePlugin function includes a method called open :
SQLitePlugin = function(openargs, openSuccess, openError) {
...
this.open(this.openSuccess, this.openError);
};
SQLitePlugin.prototype.open = function(success, error) {
var openerrorcb, opensuccesscb;
...
}
When the SQLitePlugin function is called, an error is thrown that says "Cannot read properties of undefined (reading 'open')."
The problem is caused by the fact that SQLitePlugin is defined as a function rather than a class. As a result, the open method is defined as a prototype method rather than a class method. When open is called, it's being called on an instance of the SQLitePlugin function, but the prototype method isn't being recognized.
Possible solution
To fix this issue, you've proposed converting SQLitePlugin into a class. Here's what the updated code would look like:
Error in opening the database
Cannot read properties of undefined (reading 'open')
When the SQLitePlugin function is called, an error is thrown that says "Cannot read properties of undefined (reading 'open')."
The problem is caused by the fact that SQLitePlugin is defined as a function rather than a class. As a result, the open method is defined as a prototype method rather than a class method. When open is called, it's being called on an instance of the SQLitePlugin function, but the prototype method isn't being recognized.
Possible solution
To fix this issue, you've proposed converting SQLitePlugin into a class. Here's what the updated code would look like:
By converting SQLitePlugin into a class, should allow open to be recognized when it's called. But still have another problem
After calling the "open" method i got another exception :
RangeError: Maximum call stack size exceeded at [Symbol.hasInstance] ()
_classCallCheck (...\node_modules\@babel\runtime\helpers\classCallCheck.js:2:17)