Bläddra i källkod

Fixing NPE found on issue #2695 (#2976)

There's a roundabout manner of obtaining the react context on initialisation that is null on some instances (https://github.com/wix/react-native-navigation/issues/2695), including errors on startup that prevents debugging on console. (For instance, throwing an error on index before starting the app)

It is solved by sending the same context given on method onReactContextInitialized, instead of discarding it and calling getReactContext.
Denis Ikeda 7 år sedan
förälder
incheckning
085b3c9c90

+ 3
- 3
android/app/src/main/java/com/reactnativenavigation/react/NavigationReactGateway.java Visa fil

110
 	}
110
 	}
111
 
111
 
112
 	//TODO temp hack
112
 	//TODO temp hack
113
-	private void onReactContextInitialized() {
114
-		reactEventEmitter = new NavigationReactEventEmitter(getReactContext());
113
+	private void onReactContextInitialized(ReactContext context) {
114
+		reactEventEmitter = new NavigationReactEventEmitter(context);
115
 	}
115
 	}
116
 
116
 
117
 	private static class ReactNativeHostImpl extends ReactNativeHost implements ReactInstanceManager.ReactInstanceEventListener {
117
 	private static class ReactNativeHostImpl extends ReactNativeHost implements ReactInstanceManager.ReactInstanceEventListener {
171
 
171
 
172
 		@Override
172
 		@Override
173
 		public void onReactContextInitialized(ReactContext context) {
173
 		public void onReactContextInitialized(ReactContext context) {
174
-			((NavigationReactGateway) NavigationApplication.instance.getReactGateway()).onReactContextInitialized();
174
+			((NavigationReactGateway) NavigationApplication.instance.getReactGateway()).onReactContextInitialized(context);
175
 			NavigationApplication.instance.onReactInitialized(context);
175
 			NavigationApplication.instance.onReactInitialized(context);
176
 		}
176
 		}
177
 
177