I’m migrating my project from React Native 0.59.9 to 0.61.0 (not advisable, but I have my own reasons). In my existing project I have the following code in MainApplication.java
:
JavaScript
x
20
20
1
@Override
2
protected List<ReactPackage> getPackages() {
3
return Arrays.<ReactPackage>asList(
4
new MainReactPackage(),
5
RollbarReactNative.getPackage(),
6
new VectorIconsPackage(),
7
new RNTextInputMaskPackage(),
8
new SplashScreenReactPackage(),
9
new RNSensitiveInfoPackage(),
10
new ReactNativeRestartPackage(),
11
new PickerViewPackage(),
12
new LinearGradientPackage(),
13
new ImagePickerPackage(),
14
new RNGestureHandlerPackage(),
15
new RNDeviceInfo(),
16
new A0Auth0Package(),
17
new AsyncStoragePackage()
18
);
19
}
20
In MainApplication.java
in v0.61.0 the following code is auto-generated (corresponds to the code above):
JavaScript
1
9
1
@Override
2
protected List<ReactPackage> getPackages() {
3
@SuppressWarnings("UnnecessaryLocalVariable")
4
List<ReactPackage> packages = new PackageList(this).getPackages();
5
// Packages that cannot be autolinked yet can be added manually here, for example:
6
// packages.add(new MyReactNativePackage());
7
return packages;
8
}
9
Does it make sense that I would add the packages from the first part of the code to the second like:
JavaScript
1
23
23
1
@Override
2
protected List<ReactPackage> getPackages() {
3
@SuppressWarnings("UnnecessaryLocalVariable")
4
List<ReactPackage> packages = new PackageList(this).getPackages();
5
// Packages that cannot be autolinked yet can be added manually here, for example:
6
// packages.add(new MyReactNativePackage());
7
packages.add(new MainReactPackage())
8
packages.add(RollbarReactNative.getPackage())
9
packages.add(new VectorIconsPackage())
10
packages.add(new RNTextInputMaskPackage())
11
packages.add(new SplashScreenReactPackage())
12
packages.add(new RNSensitiveInfoPackage())
13
packages.add(new ReactNativeRestartPackage())
14
packages.add(new PickerViewPackage())
15
packages.add(new LinearGradientPackage())
16
packages.add(new ImagePickerPackage())
17
packages.add(new RNGestureHandlerPackage())
18
packages.add(new RNDeviceInfo())
19
packages.add(new A0Auth0Package())
20
packages.add(new AsyncStoragePackage())
21
return packages;
22
}
23
Does this make sense?
Advertisement
Answer
You don’t need to add the packages anymore. RN0.60 and above supports auto-linking. I commented out my packages because they are no longer needed.
You will definitely get a similar warning as the image below if you add them.