Browse Source

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

Co-authored-by: Yogev Ben David <yogevbd@wix.com>
Guy Carmeli 4 years ago
parent
commit
defc2aaa6e
No account linked to committer's email address

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java View File

96
 
96
 
97
     @Override
97
     @Override
98
     public void mergeOptions(Options options) {
98
     public void mergeOptions(Options options) {
99
-        presenter.mergeOptions(options, this, getCurrentChild());
99
+        if (isViewShown()) presenter.mergeOptions(options, this, getCurrentChild());
100
         super.mergeOptions(options);
100
         super.mergeOptions(options);
101
     }
101
     }
102
 
102
 

+ 6
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.java View File

1039
         verify(uut, times(1)).mergeChildOptions(optionsToMerge, vc);
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
     @Test
1048
     @Test
1043
     public void mergeChildOptions_updatesParentControllerWithNewOptions() {
1049
     public void mergeChildOptions_updatesParentControllerWithNewOptions() {
1044
         StackController uut = TestUtils.newStackController(activity)
1050
         StackController uut = TestUtils.newStackController(activity)

+ 1
- 1
package.json View File

159
       }
159
       }
160
     }
160
     }
161
   }
161
   }
162
-}
162
+}