Skip to content

Commit

Permalink
Avoid null reference exception when fetching ReactRootView in bridgel…
Browse files Browse the repository at this point in the history
…ess (#47284)

Summary:
Pull Request resolved: #47284

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

Reviewed By: javache

Differential Revision: D65141137

fbshipit-source-id: 9b002b0520a7eeea61767cb8934e9bb8d049fc6a
  • Loading branch information
rozele authored and facebook-github-bot committed Oct 29, 2024
1 parent e3f0326 commit 0d66410
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 0d66410

Please sign in to comment.