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

Fix crash when mergeOptions were called before stack view was created (#5945)

Co-authored-by: Yogev Ben David <yogevbd@wix.com>
Guy Carmeli преди 4 години
родител
ревизия
defc2aaa6e
No account linked to committer's email address

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java Целия файл

@@ -96,7 +96,7 @@ public class StackController extends ParentController<StackLayout> {
96 96
 
97 97
     @Override
98 98
     public void mergeOptions(Options options) {
99
-        presenter.mergeOptions(options, this, getCurrentChild());
99
+        if (isViewShown()) presenter.mergeOptions(options, this, getCurrentChild());
100 100
         super.mergeOptions(options);
101 101
     }
102 102
 

+ 6
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.java Целия файл

@@ -1039,6 +1039,12 @@ public class StackControllerTest extends BaseTest {
1039 1039
         verify(uut, times(1)).mergeChildOptions(optionsToMerge, vc);
1040 1040
     }
1041 1041
 
1042
+    @Test
1043
+    public void mergeOptions_doesNotMergeOptionsIfViewIsNotVisible() {
1044
+        uut.mergeOptions(Options.EMPTY);
1045
+        verify(presenter, times(0)).mergeOptions(any(), any(), any());
1046
+    }
1047
+
1042 1048
     @Test
1043 1049
     public void mergeChildOptions_updatesParentControllerWithNewOptions() {
1044 1050
         StackController uut = TestUtils.newStackController(activity)

+ 1
- 1
package.json Целия файл

@@ -159,4 +159,4 @@
159 159
       }
160 160
     }
161 161
   }
162
-}
162
+}