Skip to content

Commit da21799

Browse files
javachefacebook-github-bot
authored andcommitted
Fix stack overflow in createRootView (#43420)
Summary: Pull Request resolved: #43420 Calling `mReactDelegate.createRootView` just ends up calling the overridden method in the anonymous inner class. Instead have the base implementation return null, and call super. Changelog: [Internal] Reviewed By: jessebwr, janeli-100005636499545 Differential Revision: D54772205 fbshipit-source-id: fc90e6718f9c287e8b86e5768cf7f74d0db06c49
1 parent 3706bf0 commit da21799

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@ public ReactActivityDelegate(
6363
return getLaunchOptions();
6464
}
6565

66+
/**
67+
* Override to customize ReactRootView creation.
68+
*
69+
* <p>Not used on bridgeless
70+
*/
6671
protected ReactRootView createRootView() {
67-
return Assertions.assertNotNull(mReactDelegate).createRootView();
72+
return null;
6873
}
6974

7075
/**
@@ -102,7 +107,11 @@ public void onCreate(Bundle savedInstanceState) {
102107
getPlainActivity(), getReactNativeHost(), mainComponentName, launchOptions) {
103108
@Override
104109
protected ReactRootView createRootView() {
105-
return ReactActivityDelegate.this.createRootView();
110+
ReactRootView rootView = ReactActivityDelegate.this.createRootView();
111+
if (rootView == null) {
112+
rootView = super.createRootView();
113+
}
114+
return rootView;
106115
}
107116
};
108117
}

0 commit comments

Comments
 (0)