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

NativeModules is empty #31

Closed
WesSouza opened this issue Jun 18, 2018 · 2 comments
Closed

NativeModules is empty #31

WesSouza opened this issue Jun 18, 2018 · 2 comments

Comments

@WesSouza
Copy link

I'm trying to use this module together with andpor/react-native-sqlite-storage, but something's preventing it from initializing correctly.

The error I could extract from the thread is:

TypeError: undefined is not an object (evaluating 'NativeModules["SQLite"][method]')

Seems to be related to line 84 on lib/sqlite.core.js that depends on the NativeModule bind for that module.

Is there a limitation on this kind of operation? I couldn't find any reference to NativeModules in the documentation.

I also found that NativeModules is an empty object inside a thread.

Module Version
React Native 0.55.4
react-native-threads 0.0.12
react-native-sqlite-storage 3.3.6
@WesSouza WesSouza changed the title TypeError: undefined is not an object (evaluating 'NativeModules["SQLite"][method]') NativeModules is empty object Jun 18, 2018
@WesSouza WesSouza changed the title NativeModules is empty object NativeModules is empty Jun 18, 2018
@Traviskn
Copy link
Contributor

Hi @wesleydesouza,

To use native packages such as react-native-sqlite-storage in a thread on Android, you will need to modify your MainApplication.java file as outlined in the android section of the README

To include additional native modules in your threads, pass them into the RNThreadPackage constructor after the mReactNativeHost like this: new RNThreadPackage(mReactNativeHost, new ExampleNativePackage(), new SQLitePackage())

On iOS the NativeModules object should not be empty.

@WesSouza
Copy link
Author

@Traviskn thanks for pointing that out!

I guess I'll open a PR and make that section a bit more prominent, or create a dedicated section referencing that somewhere in the README. 😄

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