Update docs about MainActivity getPackages
Summary: Didn't found someone that updated that, feel free to close if that is the case. Closes https://github.com/facebook/react-native/pull/5415 Reviewed By: svcscm Differential Revision: D2841576 Pulled By: androidtrunkagent fb-gh-sync-id: 99b37fcb370453ce71fa83434f7c72b598375ef0
This commit is contained in:
parent
0c5f279c9d
commit
58a448ece3
|
@ -108,20 +108,14 @@ class AnExampleReactPackage implements ReactPackage {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The package needs to be provided to the **ReactInstanceManager** when it is built. To accomplish this you will need to insert an `.addPackage(new YourPackageName())` call to the `mReactInstanceManager = ReactInstanceManager.builder()` call chain.
|
The package needs to be provided in the `getPackages` method of the `MainActivity.java` file. This file exists under the android folder in your react-native application directory. The path to this file is: `android/app/src/main/java/com/your-app-name/MainActivity.java`.
|
||||||
|
|
||||||
Refer to the code below and add the `addPackage` statement to your application's `MainActivity.java` file. This file exists under the android folder in your react-native application directory. The path to this file is: `android/app/src/main/java/com/your-app-name/MainActivity.java`.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
mReactInstanceManager = ReactInstanceManager.builder()
|
protected List<ReactPackage> getPackages() {
|
||||||
.setApplication(getApplication())
|
return Arrays.<ReactPackage>asList(
|
||||||
.setBundleAssetName("AnExampleApp.android.bundle")
|
new MainReactPackage(),
|
||||||
.setJSMainModuleName("Examples/AnExampleApp/AnExampleApp.android")
|
new AnExampleReactPackage()); // <-- Add this line with your package name.
|
||||||
.addPackage(new AnExampleReactPackage()) // <-- Add this line with your package name.
|
}
|
||||||
.setUseDeveloperSupport(true)
|
|
||||||
.setInitialLifecycleState(LifecycleState.RESUMED)
|
|
||||||
.build();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
To make it simpler to access your new functionality from JavaScript, it is common to wrap the native module in a JavaScript module. This is not necessary but saves the consumers of your library the need to pull it off of `NativeModules` each time. This JavaScript file also becomes a good location for you to add any JavaScript side functionality.
|
To make it simpler to access your new functionality from JavaScript, it is common to wrap the native module in a JavaScript module. This is not necessary but saves the consumers of your library the need to pull it off of `NativeModules` each time. This JavaScript file also becomes a good location for you to add any JavaScript side functionality.
|
||||||
|
|
Loading…
Reference in New Issue