Browse Source

Pass newly created ReactContext from ReactInstanceEventListener

Guy Carmeli 6 years ago
parent
commit
350f48aee1

+ 4
- 4
lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationReactInitializer.java View File

46
 		if (shouldCreateContext()) {
46
 		if (shouldCreateContext()) {
47
 			reactInstanceManager.createReactContextInBackground();
47
 			reactInstanceManager.createReactContextInBackground();
48
 		} else if (waitingForAppLaunchEvent) {
48
 		} else if (waitingForAppLaunchEvent) {
49
-			emitAppLaunched();
49
+			emitAppLaunched(reactInstanceManager.getCurrentReactContext());
50
 		}
50
 		}
51
 	}
51
 	}
52
 
52
 
53
-	private void emitAppLaunched() {
53
+	private void emitAppLaunched(ReactContext context) {
54
 		waitingForAppLaunchEvent = false;
54
 		waitingForAppLaunchEvent = false;
55
-		new NavigationEvent(reactInstanceManager.getCurrentReactContext()).appLaunched();
55
+		new NavigationEvent(context).appLaunched();
56
 	}
56
 	}
57
 
57
 
58
 	private boolean shouldCreateContext() {
58
 	private boolean shouldCreateContext() {
61
 
61
 
62
 	@Override
62
 	@Override
63
 	public void onReactContextInitialized(final ReactContext context) {
63
 	public void onReactContextInitialized(final ReactContext context) {
64
-		emitAppLaunched();
64
+        emitAppLaunched(context);
65
 	}
65
 	}
66
 }
66
 }