react-native-date
react-native-date copied to clipboard
React Native 0.19.0 Package Registration Error
I'm on step 4 in the readme, registering the react package. Android studio is giving me error on these lines for passing in this to the ReactDatePackage:
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
, new ReactDatePackage(this)
);
Is there a new way to register packages like this?
The error is a bit cryptic, it says:
asList() cannot be applied to:
Expected Parameters: array: com.facebook.react.ReactPackage...
Actual Arguments: new MainReactPackage() (com.facebook.react.shell.MainReactPackage)
new ReactDatePackage(this) (me.nucleartux.date.ReactDatePackage)
And it only appears when I pass 'this' to the ReactDatePackage constructor
After toying around with this in my own project, it seems that react-native 0.19.0 has introduced a new method getCurrentActivity that you can use in your module to access the current Activity. This means you are no longer required to pass the MainActivity down through the constructor.