|
1 | 1 | package com.awesomeproject |
2 | 2 |
|
3 | 3 | import android.app.Application |
4 | | -import cn.reactnative.modules.update.UpdateContext |
5 | 4 | import com.facebook.react.PackageList |
6 | 5 | import com.facebook.react.ReactApplication |
7 | 6 | import com.facebook.react.ReactHost |
8 | 7 | import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative |
9 | | -import com.facebook.react.ReactNativeHost |
10 | | -import com.facebook.react.ReactPackage |
11 | 8 | import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost |
12 | | -import com.facebook.react.defaults.DefaultReactNativeHost |
| 9 | +import cn.reactnative.modules.update.UpdateContext |
13 | 10 |
|
14 | 11 | class MainApplication : Application(), ReactApplication { |
15 | 12 |
|
16 | | - override val reactNativeHost: ReactNativeHost = |
17 | | - object : DefaultReactNativeHost(this) { |
18 | | - |
19 | | - override fun getJSBundleFile(): String? = UpdateContext.getBundleUrl(this@MainApplication) |
20 | | - |
21 | | - override fun getPackages(): List<ReactPackage> = |
22 | | - PackageList(this).packages.apply { |
23 | | - // Packages that cannot be autolinked yet can be added manually here, for example: |
24 | | - // add(MyReactNativePackage()) |
25 | | - } |
26 | | - |
27 | | - override fun getJSMainModuleName(): String = "index" |
28 | | - |
29 | | - override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG |
30 | | - |
31 | | - override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED |
32 | | - override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED |
33 | | - } |
34 | | - |
35 | | - override val reactHost: ReactHost |
36 | | - get() = getDefaultReactHost(applicationContext, reactNativeHost) |
| 13 | + override val reactHost: ReactHost by lazy { |
| 14 | + getDefaultReactHost( |
| 15 | + context = applicationContext, |
| 16 | + packageList = |
| 17 | + PackageList(this).packages.apply { |
| 18 | + // Packages that cannot be auto-linked yet can be added manually here, for example: |
| 19 | + // add(MyReactNativePackage()) |
| 20 | + }, |
| 21 | + jsBundleFilePath = UpdateContext.getBundleUrl(this), |
| 22 | + ) |
| 23 | + } |
37 | 24 |
|
38 | 25 | override fun onCreate() { |
39 | 26 | super.onCreate() |
|
0 commit comments