Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Native: null is not an object (NativeModules[SQLite][method]) #3915

Closed
matheusgrieger opened this issue Mar 28, 2019 · 2 comments
Closed

Comments

@matheusgrieger
Copy link

Issue type:

[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[x] react-native
[ ] expo

TypeORM version:

[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

I have just created a new project using react-native init Project --template typescript (which is the official way of starting a new project with TypeScript now), configured and installed everything, but the app fails when creating a connection. Here is a screenshot of what shows up:

Screenshot_1553805863

Config files:

babel.config.js

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    'babel-plugin-transform-typescript-metadata',
    ['@babel/plugin-proposal-decorators', { legacy: true }],
    // ['@babel/plugin-proposal-class-properties', { loose: true }]
  ]
};

(class-properties is commented due to another issue with Babel 7 and Flow)

App.tsx#connect

  async connect() {
    await createConnection({
      type: 'react-native',
      database: 'gestor',
      location: 'default',
      logging: ['error', 'query', 'schema'],
      synchronize: true,
      entities: Object.values(models) // this evaluates to an array of entity classes
    });
    Alert.alert('hello!');
    this.setState({ loading: false });
  }
@matheusgrieger
Copy link
Author

Nevermind. For anyone in the future with the same error, using react-native link or react-native install does not work with react-native-sqlite-storage. You have to add the dependencies manually.

@prasad456
Copy link

does not work for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants