Skip to content

Commit 03d526f

Browse files
committed
Fix bridge mode by constructing ReactDelegate correctly. (#43999)
Summary: Pull Request resolved: #43999 Currently NewArch-BridgeMode is partially broken when creating views via `ReactDelegate`. That's because we're using the ctor that doesn't account for `Boolean: fabricEnabled`. That means that the `RootView` that it will be created are all having setIsFabric(FALSE). This is causing problems like whitescreens on several reload + multiple warnings such as: ``` E com.facebook.react.bridge.ReactNoCrashSoftException: Cannot get UIManager because the context doesn't contain an active CatalystInstance. ``` Fixes #43692 See for more context on this issues: #43692 Changelog: [Android] [Fixed] - Fix bridge mode by constructing ReactDelegate correctly Reviewed By: cipolleschi Differential Revision: D55921078 fbshipit-source-id: 2c21d089a49538402d546177bcdb26c8d7d5fbc1
1 parent 4eb0534 commit 03d526f

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ protected void onCreate(Bundle savedInstanceState) {
109109
} else {
110110
mReactDelegate =
111111
new ReactDelegate(
112-
getPlainActivity(), getReactNativeHost(), mainComponentName, launchOptions) {
112+
getPlainActivity(),
113+
getReactNativeHost(),
114+
mainComponentName,
115+
launchOptions,
116+
isFabricEnabled()) {
113117
@Override
114118
protected ReactRootView createRootView() {
115119
return ReactActivityDelegate.this.createRootView(launchOptions);

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ public class ReactDelegate {
4545

4646
private boolean mFabricEnabled = false;
4747

48+
/**
49+
* Do not use this constructor as it's not accounting for New Architecture at all. You should
50+
* either use {@link ReactDelegate#ReactDelegate(Activity, ReactHost, String, Bundle)} if you're
51+
* on bridgeless mode or {@link ReactDelegate#ReactDelegate(Activity, ReactNativeHost, String,
52+
* Bundle, boolean)} and use the last parameter to toggle paper/fabric.
53+
*
54+
* @deprecated Use one of the other constructors instead to account for New Architecture.
55+
*/
56+
@Deprecated
4857
public ReactDelegate(
4958
Activity activity,
5059
ReactNativeHost reactNativeHost,

0 commit comments

Comments
 (0)