Skip to content

Commit

Permalink
fix: ReactDelegate crashing New Architecture apps by invoking `setCon…
Browse files Browse the repository at this point in the history
…tentView`

Summary:
Fixes facebook#46566

Currently `ReactFragment` and `ReactDelegate` don't work in OSS + New Architecture because we call `Activity.setContentView`
on the host activity.

That result on us replacing the whole activity layout, even when the user wants to use a Fragment.
As we do have `ReactActivityDelegate` that already does this:
https://github.com/facebook/react-native/blob/94b77938435693792e57c96d76691d58d7361530/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java#L138

So this call is unncessary.

I've also updated the relative documentation here:
facebook/react-native-website#4232

Changelog:
[Android] [Fixed] - fix: ReactDelegate/ReactFragment crashing on New Architecture apps

Differential Revision: D63464367
  • Loading branch information
cortinico authored and facebook-github-bot committed Sep 26, 2024
1 parent 763f268 commit 5eb5061
Showing 1 changed file with 0 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,7 @@ public void loadApp(String appKey) {
// With Bridgeless enabled, create and start the surface
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
if (mReactSurface == null) {
// Create a ReactSurface
mReactSurface = mReactHost.createSurface(mActivity, appKey, mLaunchOptions);
// Set main Activity's content view
mActivity.setContentView(mReactSurface.getView());
}
mReactSurface.start();
} else {
Expand Down

0 comments on commit 5eb5061

Please sign in to comment.