Skip to content

Commit aec35b8

Browse files
Juan Penalozafacebook-github-bot
authored andcommitted
Revert D80622058: Remove deprecated DefaultReactHost.getDefaultReactHost() overload - part 1
Differential Revision: D80622058 Original commit changeset: 4667683be151 Original Phabricator Diff: D80622058 fbshipit-source-id: c6c119df3b4f849a5c66fbbb619017ae837260c8
1 parent 3c79d7c commit aec35b8

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,10 +1865,12 @@ public final class com/facebook/react/defaults/DefaultReactHost {
18651865
public static final fun getDefaultReactHost (Landroid/content/Context;Lcom/facebook/react/ReactNativeHost;Lcom/facebook/react/runtime/JSRuntimeFactory;)Lcom/facebook/react/ReactHost;
18661866
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;
18671867
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;
1868+
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;
18681869
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;
18691870
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;
18701871
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;
18711872
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;
1873+
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;
18721874
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;
18731875
}
18741876

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,63 @@ public object DefaultReactHost {
220220
bindingsInstaller,
221221
)
222222

223+
/**
224+
* Util function to create a default [ReactHost] to be used in your application. This method is
225+
* used by the New App template.
226+
*
227+
* @param context the Android [Context] to use for creating the [ReactHost]
228+
* @param packageList the list of [ReactPackage]s to use for creating the [ReactHost]
229+
* @param jsMainModulePath the path to your app's main module on Metro. Usually `index` or
230+
* `index.<platform>`
231+
* @param jsBundleAssetPath the path to the JS bundle relative to the assets directory. Will be
232+
* composed in a `asset://...` URL
233+
* @param jsBundleFilePath the path to the JS bundle on the filesystem. Will be composed in a
234+
* `file://...` URL
235+
* @param isHermesEnabled whether to use Hermes as the JS engine, default to true.
236+
* @param useDevSupport whether to enable dev support, default to ReactBuildConfig.DEBUG.
237+
* @param cxxReactPackageProviders a list of cxxreactpackage providers (to register c++ turbo
238+
* modules)
239+
*/
240+
@Deprecated(
241+
message = "Use `getDefaultReactHost` with `jsRuntimeFactory` instead",
242+
replaceWith =
243+
ReplaceWith(
244+
"""
245+
fun getDefaultReactHost(
246+
context: Context,
247+
packageList: List<ReactPackage>,
248+
jsMainModulePath: String,
249+
jsBundleAssetPath: String,
250+
jsBundleFilePath: String?,
251+
jsRuntimeFactory: JSRuntimeFactory?,
252+
useDevSupport: Boolean,
253+
cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage>,
254+
): ReactHost
255+
"""
256+
),
257+
)
258+
@JvmStatic
259+
public fun getDefaultReactHost(
260+
context: Context,
261+
packageList: List<ReactPackage>,
262+
jsMainModulePath: String = "index",
263+
jsBundleAssetPath: String = "index",
264+
jsBundleFilePath: String? = null,
265+
isHermesEnabled: Boolean = true,
266+
useDevSupport: Boolean = ReactBuildConfig.DEBUG,
267+
cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage> = emptyList(),
268+
): ReactHost =
269+
getDefaultReactHost(
270+
context,
271+
packageList,
272+
jsMainModulePath,
273+
jsBundleAssetPath,
274+
jsBundleFilePath,
275+
HermesInstance(),
276+
useDevSupport,
277+
cxxReactPackageProviders,
278+
)
279+
223280
/**
224281
* Util function to create a default [ReactHost] to be used in your application. This method is
225282
* used by the New App template.

0 commit comments

Comments
 (0)