Skip to content

Commit

Permalink
Add null check for instance manager
Browse files Browse the repository at this point in the history
Summary:
## Summary
Calling `getCurrentReactContext` on an unmounted `ReactRootView` could lead to a NPE. The method currently returns a nullable value so return type is the exact same. This change checks if the react instance manager is present and returns null early if not.

## Changelog:
[Android] [Fixed] - Adds a null check in react context getter

Differential Revision: D59982179
  • Loading branch information
Abbondanzo authored and facebook-github-bot committed Jul 19, 2024
1 parent 123d7d4 commit b1c2f70
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,9 @@ public boolean hasActiveReactContext() {

@Nullable
public ReactContext getCurrentReactContext() {
if (mReactInstanceManager == null) {
return null;
}
return mReactInstanceManager.getCurrentReactContext();
}

Expand Down

0 comments on commit b1c2f70

Please sign in to comment.