Skip to content

Commit 9981e35

Browse files
Keep only release level on DefaultNewArchitectureEntryPoint (#58469)
Summary: TurboModules, Fabric and bridgeless are all unconditionally enabled in the New Architecture, so every remaining flag on `DefaultNewArchitectureEntryPoint` was dead configuration. Reduce it to the one thing it still selects: the release level. Removes the deprecated parameterized `load(...)` overloads, the `fabricEnabled`, `turboModulesEnabled` and `concurrentReactEnabled` getters, and `isConfigurationValid`. Call sites that passed `fabricEnabled` to `DefaultReactActivityDelegate` now use its two-argument constructor, which already ignored the flag. Changelog: [Android][Breaking] - Remove the deprecated `DefaultNewArchitectureEntryPoint.load(turboModulesEnabled, fabricEnabled)` overloads; use `load()` instead [Android][Breaking] - Remove `DefaultNewArchitectureEntryPoint.fabricEnabled`, `turboModulesEnabled`, `concurrentReactEnabled` and `isConfigurationValid` Reviewed By: javache Differential Revision: D119370657
1 parent be53e3a commit 9981e35

4 files changed

Lines changed: 5 additions & 157 deletions

File tree

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,15 +1768,8 @@ public final class com/facebook/react/defaults/DefaultComponentsRegistry {
17681768

17691769
public final class com/facebook/react/defaults/DefaultNewArchitectureEntryPoint {
17701770
public static final field INSTANCE Lcom/facebook/react/defaults/DefaultNewArchitectureEntryPoint;
1771-
public static final fun getConcurrentReactEnabled ()Z
1772-
public static final fun getFabricEnabled ()Z
17731771
public final fun getReleaseLevel ()Lcom/facebook/react/common/ReleaseLevel;
1774-
public static final fun getTurboModulesEnabled ()Z
17751772
public static final fun load ()V
1776-
public static final fun load (Z)V
1777-
public static final fun load (ZZ)V
1778-
public static synthetic fun load$default (ZILjava/lang/Object;)V
1779-
public static synthetic fun load$default (ZZILjava/lang/Object;)V
17801773
public final fun setReleaseLevel (Lcom/facebook/react/common/ReleaseLevel;)V
17811774
}
17821775

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

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
@file:Suppress("DEPRECATION") // We want to use ReactFeatureFlags here specifically
9-
108
package com.facebook.react.defaults
119

1210
import com.facebook.react.common.ReleaseLevel
13-
import com.facebook.react.common.annotations.VisibleForTesting
1411
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
1512
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsOverrides_RNOSS_Canary_Android
1613
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android
@@ -20,71 +17,28 @@ import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsProvider
2017
/**
2118
* A utility class that serves as an entry point for users setup the New Architecture.
2219
*
23-
* This class needs to be invoked as `DefaultNewArchitectureEntryPoint.load(...)` by passing a
24-
* series of optional parameters.
20+
* This class needs to be invoked as `DefaultNewArchitectureEntryPoint.load()`, optionally after
21+
* setting [releaseLevel] to pick the set of feature flags to apply.
2522
*
2623
* By default it loads a library called `appmodules`. `appmodules` is a convention used to refer to
2724
* the application dynamic library. If changed here should be updated also inside the template.
28-
*
29-
* By default it also enables both TurboModules, Fabric and Concurrent React (aka React 18), and
30-
* Bridgeless
3125
*/
3226
public object DefaultNewArchitectureEntryPoint {
3327

3428
public var releaseLevel: ReleaseLevel = ReleaseLevel.STABLE
3529

36-
/**
37-
* Loads the React Native New Architecture entry point with the default configuration.
38-
*
39-
* This will load the app with TurboModules, Fabric and Bridgeless by default.
40-
*/
30+
/** Loads the React Native New Architecture entry point for the configured [releaseLevel]. */
4131
@JvmStatic
4232
public fun load() {
43-
load(turboModulesEnabled = true, fabricEnabled = true)
44-
}
45-
46-
@JvmStatic
47-
@Deprecated(
48-
message =
49-
"Loading the entry point with different flags for Fabric and TurboModule is deprecated." +
50-
" Please use load() instead when loading the New Architecture.",
51-
replaceWith = ReplaceWith("load()"),
52-
)
53-
public fun load(
54-
turboModulesEnabled: Boolean = true,
55-
) {
56-
load(turboModulesEnabled, fabricEnabled = true)
57-
}
58-
59-
@JvmStatic
60-
@Deprecated(
61-
message =
62-
"Loading the entry point with different flags for Fabric and TurboModule is deprecated." +
63-
" Please use load() instead when loading the New Architecture.",
64-
replaceWith = ReplaceWith("load()"),
65-
)
66-
public fun load(
67-
turboModulesEnabled: Boolean = true,
68-
fabricEnabled: Boolean = true,
69-
) {
70-
val (isValid, errorMessage) = isConfigurationValid(turboModulesEnabled, fabricEnabled)
71-
if (!isValid) {
72-
error(errorMessage)
73-
}
74-
7533
ReactNativeFeatureFlags.override(getDefaultFeatureFlagsProvider())
7634

77-
privateTurboModulesEnabled = turboModulesEnabled
78-
7935
DefaultSoLoader.maybeLoadSoLibrary()
8036
}
8137

8238
@JvmStatic
8339
internal fun loadWithFeatureFlags(featureFlags: ReactNativeFeatureFlagsProvider) {
8440
ReactNativeFeatureFlags.override(featureFlags)
8541

86-
privateTurboModulesEnabled = true
87-
8842
DefaultSoLoader.maybeLoadSoLibrary()
8943
}
9044

@@ -94,33 +48,4 @@ public object DefaultNewArchitectureEntryPoint {
9448
ReleaseLevel.CANARY -> ReactNativeFeatureFlagsOverrides_RNOSS_Canary_Android()
9549
ReleaseLevel.STABLE -> ReactNativeFeatureFlagsOverrides_RNOSS_Stable_Android()
9650
}
97-
98-
@JvmStatic
99-
public val fabricEnabled: Boolean
100-
get() = true
101-
102-
private var privateTurboModulesEnabled: Boolean = false
103-
104-
@JvmStatic
105-
public val turboModulesEnabled: Boolean
106-
get() = privateTurboModulesEnabled
107-
108-
@JvmStatic
109-
public val concurrentReactEnabled: Boolean
110-
get() = true
111-
112-
@VisibleForTesting
113-
public fun isConfigurationValid(
114-
turboModulesEnabled: Boolean,
115-
fabricEnabled: Boolean,
116-
): Pair<Boolean, String> =
117-
if (!turboModulesEnabled || !fabricEnabled) {
118-
false to
119-
"You cannot load React Native with the New Architecture disabled. " +
120-
"Please use DefaultNewArchitectureEntryPoint.load() instead of " +
121-
"DefaultNewArchitectureEntryPoint.load(turboModulesEnabled=$turboModulesEnabled, " +
122-
"fabricEnabled=$fabricEnabled)"
123-
} else {
124-
true to ""
125-
}
12651
}

‎packages/react-native/ReactAndroid/src/test/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPointTest.kt‎

Lines changed: 0 additions & 66 deletions
This file was deleted.

‎private/helloworld/android/app/src/main/java/com/helloworld/MainActivity.kt‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package com.helloworld
99

1010
import com.facebook.react.ReactActivity
1111
import com.facebook.react.ReactActivityDelegate
12-
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
1312
import com.facebook.react.defaults.DefaultReactActivityDelegate
1413

1514
class MainActivity : ReactActivity() {
@@ -20,10 +19,7 @@ class MainActivity : ReactActivity() {
2019
*/
2120
override fun getMainComponentName(): String = "HelloWorld"
2221

23-
/**
24-
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
25-
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
26-
*/
22+
/** Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]. */
2723
override fun createReactActivityDelegate(): ReactActivityDelegate =
28-
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
24+
DefaultReactActivityDelegate(this, mainComponentName)
2925
}

0 commit comments

Comments
 (0)