diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 44b1e7cfe73..935443a962f 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -1865,10 +1865,12 @@ public final class com/facebook/react/defaults/DefaultReactHost { public static final fun getDefaultReactHost (Landroid/content/Context;Lcom/facebook/react/ReactNativeHost;Lcom/facebook/react/runtime/JSRuntimeFactory;)Lcom/facebook/react/ReactHost; public static final fun getDefaultReactHost (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/runtime/JSRuntimeFactory;ZLjava/util/List;)Lcom/facebook/react/ReactHost; public static final fun getDefaultReactHost (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/runtime/JSRuntimeFactory;ZLjava/util/List;Lkotlin/jvm/functions/Function1;Lcom/facebook/react/runtime/BindingsInstaller;)Lcom/facebook/react/ReactHost; + public static final fun getDefaultReactHost (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;)Lcom/facebook/react/ReactHost; public static final fun getDefaultReactHost (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;Lkotlin/jvm/functions/Function1;Lcom/facebook/react/runtime/BindingsInstaller;)Lcom/facebook/react/ReactHost; public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Lcom/facebook/react/ReactNativeHost;Lcom/facebook/react/runtime/JSRuntimeFactory;ILjava/lang/Object;)Lcom/facebook/react/ReactHost; public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/runtime/JSRuntimeFactory;ZLjava/util/List;ILjava/lang/Object;)Lcom/facebook/react/ReactHost; public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/runtime/JSRuntimeFactory;ZLjava/util/List;Lkotlin/jvm/functions/Function1;Lcom/facebook/react/runtime/BindingsInstaller;ILjava/lang/Object;)Lcom/facebook/react/ReactHost; + public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;ILjava/lang/Object;)Lcom/facebook/react/ReactHost; public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;Lkotlin/jvm/functions/Function1;Lcom/facebook/react/runtime/BindingsInstaller;ILjava/lang/Object;)Lcom/facebook/react/ReactHost; } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt index e6c62e17e73..bc11a5791a3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt @@ -220,6 +220,63 @@ public object DefaultReactHost { bindingsInstaller, ) + /** + * Util function to create a default [ReactHost] to be used in your application. This method is + * used by the New App template. + * + * @param context the Android [Context] to use for creating the [ReactHost] + * @param packageList the list of [ReactPackage]s to use for creating the [ReactHost] + * @param jsMainModulePath the path to your app's main module on Metro. Usually `index` or + * `index.` + * @param jsBundleAssetPath the path to the JS bundle relative to the assets directory. Will be + * composed in a `asset://...` URL + * @param jsBundleFilePath the path to the JS bundle on the filesystem. Will be composed in a + * `file://...` URL + * @param isHermesEnabled whether to use Hermes as the JS engine, default to true. + * @param useDevSupport whether to enable dev support, default to ReactBuildConfig.DEBUG. + * @param cxxReactPackageProviders a list of cxxreactpackage providers (to register c++ turbo + * modules) + */ + @Deprecated( + message = "Use `getDefaultReactHost` with `jsRuntimeFactory` instead", + replaceWith = + ReplaceWith( + """ + fun getDefaultReactHost( + context: Context, + packageList: List, + jsMainModulePath: String, + jsBundleAssetPath: String, + jsBundleFilePath: String?, + jsRuntimeFactory: JSRuntimeFactory?, + useDevSupport: Boolean, + cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage>, + ): ReactHost + """ + ), + ) + @JvmStatic + public fun getDefaultReactHost( + context: Context, + packageList: List, + jsMainModulePath: String = "index", + jsBundleAssetPath: String = "index", + jsBundleFilePath: String? = null, + isHermesEnabled: Boolean = true, + useDevSupport: Boolean = ReactBuildConfig.DEBUG, + cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage> = emptyList(), + ): ReactHost = + getDefaultReactHost( + context, + packageList, + jsMainModulePath, + jsBundleAssetPath, + jsBundleFilePath, + HermesInstance(), + useDevSupport, + cxxReactPackageProviders, + ) + /** * Util function to create a default [ReactHost] to be used in your application. This method is * used by the New App template.