mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add null check for instance manager (#45549)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45549 ## 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 Reviewed By: zeyap Differential Revision: D59982179 fbshipit-source-id: bac5c12e7dc4ee3296991063eb3746141b8446bc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
123d7d4229
commit
aeb020dfa3
@@ -817,6 +817,9 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
||||
|
||||
@Nullable
|
||||
public ReactContext getCurrentReactContext() {
|
||||
if (mReactInstanceManager == null) {
|
||||
return null;
|
||||
}
|
||||
return mReactInstanceManager.getCurrentReactContext();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user