joltup / react-native-threads

Create new JS processes for CPU intensive work
MIT License
755 stars 141 forks source link

On RN 61 we have errors. #81

Open neller1 opened 5 years ago

neller1 commented 5 years ago

Because netinfo module was deleted in RN 61 we have error: ThreadBaseReactPackage.java:13: error: package com.facebook.react.modules.netinfo does not exist

I commented 13 and 49 strings in ThreadBaseReactPackage.java to temporary start project

dwhitney commented 5 years ago

I've done this, but I get a compile error

/TestNative/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:51: error: constructor RNThreadPackage in class RNThreadPackage cannot be applied to given types;
      new RNThreadPackage()
      ^
  required: ReactNativeHost,ReactPackage[]
  found: no arguments
  reason: actual and formal argument lists differ in length
1 error

FAILURE: Build failed with an exception.

I've definitely added the relevant lines to getPackages - here's a cut/paste

        @Override
        protected List<ReactPackage> getPackages() {
          @SuppressWarnings("UnnecessaryLocalVariable")
          List<ReactPackage> packages = new PackageList(this).getPackages();
          packages.add(new RNThreadPackage(mReactNativeHost));
          return packages;
       }

Any suggestions?

minicuper commented 5 years ago

The same problem. Tried to use tarball version - "react-native-threads": "http://github.com/joltup/react-native-threads/tarball/master"

but it leads to the same error: "error: package com.facebook.react.modules.netinfo does not exist import com.facebook.react.modules.netinfo.NetInfoModule;"

Do we plan to update rnt for 61? Or maybe there are alternatives?

minicuper commented 5 years ago

Found how to do the trick.

  1. use https://github.com/jhen0409/react-native-threads/tree/rn61 (or just remove 13 and 49 lines as in the first topic) yarn add http://github.com/jhen0409/react-native-threads/tarball/rn61
    or npm i http://github.com/jhen0409/react-native-threads/tarball/rn61

  2. manually link the package react-native link react-native-threads

  3. turn off linking for android (according to https://github.com/joltup/react-native-threads/pull/76 and https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#how-can-i-disable-autolinking-for-unsupported-library)

    // react-native.config.js
    module.exports = {
    dependencies: {
    'react-native-threads': {
      platforms: {
        android: null, 
      },
    },
    },
    };

Dirty hacks but working...

minicuper commented 5 years ago

So, now we have 2 issues to get 61:

  1. need to remove netinfo package (the 13, 49 lines in the ThreadBaseReactPackage.java)
  2. somehow setup auto-linking for 61 (taking into account that RNThreadPackage requires additional parameters: at least ReactNativeHost + additional native packages that should be available in the Thread)
ihavenoface5 commented 5 years ago

84

jacobp100 commented 5 years ago

I was able to fix this by adding this file to the root,

// react-native.config.js
module.exports = {
  dependencies: {
    'react-native-threads': {
      platforms: {
        android: null, 
      },
    },
  },
};

And then just following the manual linking step. I didn't need to use another repo, this one worked fine with the above