Browse Source

Check if react has already been instantiated

When returning to foreground after `onRestart` react context should
not be initialised since activity was not destroyed when going to background.
Guy Carmeli 8 years ago
parent
commit
974a8ea697

+ 4
- 2
android/app/src/main/java/com/reactnativenavigation/activities/RootActivity.java View File

18
     @Override
18
     @Override
19
     protected void handleOnCreate() {
19
     protected void handleOnCreate() {
20
         super.handleOnCreate();
20
         super.handleOnCreate();
21
-        // Trigger react context initialization, global javascript code will now execute
22
-        getReactInstanceManager().createReactContextInBackground();
21
+        if (!getReactInstanceManager().hasStartedCreatingInitialContext()) {
22
+            // Trigger react context initialization, global javascript code will now execute
23
+            getReactInstanceManager().createReactContextInBackground();
24
+        }
23
     }
25
     }
24
 
26
 
25
     @Override
27
     @Override