Преглед на файлове

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 години
родител
ревизия
974a8ea697
променени са 1 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 4
    2
      android/app/src/main/java/com/reactnativenavigation/activities/RootActivity.java

+ 4
- 2
android/app/src/main/java/com/reactnativenavigation/activities/RootActivity.java Целия файл

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