I have a few existing React Packages which are added as library to my current react native app.
Now, one of the packages, needs to be added only if certain condition follows:
Condition : If 'isXPackageRequired' is true, then only it should be added as list of react packages. But this property is in javascript code and should only be read from redux store.
Following is the code where i am adding react packages:
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
List<ReactPackage> reactPackages = Arrays.<ReactPackage>asList(
new MainReactPackage(),
...,// Some other Packages
);
// Here how can i get that redux variable to conditionally include myXPackage
if(**CONDITION WITH JAVASCRIPT VARIABLE:isXPackageRequired**){
reactPackageList.add(new MyXPackage());
}
}
}
OR, is there any other place where i can remove this package if already added and how?
I could have read from buildConfig if it would have been static or environment based, but the ask is at the runtime and if we have the desired property in our redux-store.
I have researched a lot but with no luck. Any elegant solution will be much appreciated.
Thanks in advance.