Skip to content

Commit

Permalink
Avoid null reference exception when fetching ReactRootView in bridgeless
Browse files Browse the repository at this point in the history
Summary:
If the surface hasn't been set up yet, attempting to fetch the ReactRootView will throw a null reference exception. Since the result is already nullable, it's perhaps better to just return null when the surface has not yet been initialized.

## Changelog

[Android][Fixed] Avoid null reference exception in bridgeless ReactDelegate

Differential Revision: D65141137
  • Loading branch information
rozele authored and facebook-github-bot committed Oct 29, 2024
1 parent 5f45f8a commit 21e4584
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ public void unloadApp() {
@Nullable
public ReactRootView getReactRootView() {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
return (ReactRootView) mReactSurface.getView();
if (mReactSurface != null) {
return (ReactRootView) mReactSurface.getView();
} else {
return null;
}
} else {
return mReactRootView;
}
Expand Down

0 comments on commit 21e4584

Please sign in to comment.