Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read property 'debugHosts' of undefined

Tags:

I'm getting this error while trying to use Realm with RN 0.29

Stack trace from chrome:

"Cannot read property 'debugHosts' of undefined"
handleException @   ExceptionsManager.js:55
handleError @   InitializeJavaScriptAppEngine.js:136
reportFatalError    @   error-guard.js:30
guardedLoadModule   @   require.js:60
_require    @   require.js:49
(anonymous function)    @   require-0.js:1
executeApplicationScript    @   debuggerWorker.js:18
onmessage   @   debuggerWorker.js:33

The device is pointing to the index.js file in the node_modules/realm/lib/index.js in this line: const {debugHosts, debugPort} = NativeModules.Realm;

One thing I tried was removing all degbugHosts related stuff in the js files, and It throws Must first create RPC session with a valid host...

Someone said that it's working on RN 0.28 but I would like to fix it instead of downgrading RN just for this module.

like image 650
Computer's Guy Avatar asked Jul 16 '16 05:07

Computer's Guy


1 Answers

Steps to fix:

rnpm link realm

Add the module in the MainApplication.Java file, should look like this

 @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new RealmReactPackage() // this
      );
    }
  };

rebuild/clean/etc

Also, may need to add android:name=".MainApplication" in the AndroidManifest.xml -> <application

like image 100
Computer's Guy Avatar answered Sep 28 '22 03:09

Computer's Guy