[Tutorial] Cannot read property 'initialize' of undefined
See original GitHub issueI followed the instructions for creating the db tutorial. I got the following error
Unhandled JS Exception: TypeError: Cannot read property 'initialize' of undefined
. Thinking I did something wrong, I recreated it. Same error. I’ve scoured the internet for a solution without success.
My environment
package.json
{
"name": "movie_directory",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@nozbe/watermelondb": "^0.16.1",
"@nozbe/with-observables": "^1.0.5",
"native-base": "^2.13.12",
"rambdax": "^3.7.0",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-fullwidth-image": "^0.1.3",
"react-native-gesture-handler": "^1.6.1",
"react-navigation": "^4.3.9"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/plugin-proposal-decorators": "^7.8.3",
"@babel/runtime": "^7.6.2",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.58.0",
"react-test-renderer": "16.11.0"
},
"jest": {
"preset": "react-native"
}
}
The error occurs in the index.js
file when it can’t initialize the SQLiteAdapter
. Is there any known issues with using Watermelon with the latest react-native
version? This is a blocker because the app does not compile.
Here is the index.js file // index.js
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import {Database} from '@nozbe/watermelondb';
import SQLiteAdapter from '@nozbe/watermelondb/adapters/sqlite';
import {mySchema} from './src/models/schema';
import {dbModels} from './src/models/index.js';
// First, create the adapter to the underlying database:
const adapter = new SQLiteAdapter({
dbName: 'WatermelonDemo',
schema: mySchema,
});
// Then, make a Watermelon database from it!
const database = new Database({
adapter,
modelClasses: dbModels,
});
AppRegistry.registerComponent(appName, () => App);
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Uncaught TypeError: Cannot read property 'initialize' of ...
Currently I am working on an Upgradation project; I am facing the Below Exception when I instantiate the Custom Router Class from the...
Read more >Uncaught TypeError: Cannot read property ... - SAP Community
Hi, I have developed UI5 application and deployed into ABAP server. When I try to run on ABAP server from Eclipse it is...
Read more >Cannot read properties of undefined' - JavaScript Debugging
JavaScript Tutorial. How To Fix 'Uncaught TypeError: Cannot read properties of undefined ' - JavaScript Debugging. 26K views 6 months ago.
Read more >ERROR TypeError: Cannot read property title of undefined
HEY, SET YOUR LIKE THERE ! ... Your browser can't play this video. ... Solved: ERROR TypeError: Cannot read property title of undefined....
Read more >Uncaught TypeError : Cannot read properties of undefined
As we are discussing the Error Uncaught TypeError: Cannot read property of undefined, let's understand the JavaScript built-in error first, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m reopening because the issue still exists when working from a fresh install. Thanks, @jdnichollsc for assistance. But your app is written in Typescript which I don’t use. I followed the tutorial verbatim except for passing the
database
object to the navigation handler. I don’t need it for this PoC. Also, I factored db ops into it’s own component.Database.js
I import this into
App.js
withimport {HomeeDb} from './services/Database';
Then call it withconst db = HomeeDb();
. The app crashes when trying to initialize the adapter. I tried to step through it but it’s crashing in the node module.Thanks, @jdnichollsc, your demo may come in handy.