Skip to content

Commit 6d4f6fe

Browse files
cortinicofacebook-github-bot
authored andcommitted
Simplify new app template for bridgeless (#40929)
Summary: Pull Request resolved: facebook/react-native#40929 This diff reduces the footprint that bridgeless is imposing on the new app template. Specifically: - I've created a `.toReactHost` method that converts a DefaultReactNativeHost to a DefaultReactHost - I've updated RN Tester to use the same setup as the New App template which reduces code duplication. I also had to remove a couple of `UnstableReactNativeAPI` as those were bleeding in the new app template. I don't think we should ask users to opt-in in `UnstableReactNativeAPI` in the New App template itself as this means that all the apps will get this opt-in. Instead we should keep it only for specific APIs that we want the users to opt into. Changelog: [Internal] [Changed] - Simplify new app template for bridgeless Reviewed By: cipolleschi, luluwu2032 Differential Revision: D50227693 fbshipit-source-id: e86c54d5156cc27f1f898b43ca89c57d5cf148b8 Original-Commit: facebook/react-native@a7f9080
1 parent a0c07ff commit 6d4f6fe

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

template/template/android/app/src/main/java/com/helloworld/MainApplication.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ import com.facebook.react.ReactApplication
66
import com.facebook.react.ReactHost
77
import com.facebook.react.ReactNativeHost
88
import com.facebook.react.ReactPackage
9-
import com.facebook.react.common.annotations.UnstableReactNativeAPI
109
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
11-
import com.facebook.react.defaults.DefaultReactHost
10+
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
1211
import com.facebook.react.defaults.DefaultReactNativeHost
1312
import com.facebook.soloader.SoLoader
1413

15-
@UnstableReactNativeAPI
1614
class MainApplication : Application(), ReactApplication {
1715

1816
override val reactNativeHost: ReactNativeHost =
@@ -32,12 +30,7 @@ class MainApplication : Application(), ReactApplication {
3230
}
3331

3432
override val reactHost: ReactHost
35-
get() =
36-
DefaultReactHost.getDefaultReactHost(
37-
context = this,
38-
packageList = PackageList(this).packages,
39-
jsMainModulePath = "index",
40-
isHermesEnabled = BuildConfig.IS_HERMES_ENABLED)
33+
get() = getDefaultReactHost(this.applicationContext, reactNativeHost)
4134

4235
override fun onCreate() {
4336
super.onCreate()

0 commit comments

Comments
 (0)