Skip to content

Commit bd72974

Browse files
authored
fix (#8258)
* fix * test update
1 parent 5a399ae commit bd72974

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

ios/BottomTabPresenter.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ - (void)mergeOptions:(RNNNavigationOptions *)mergeOptions
3838

3939
- (void)createTabBarItem:(UIViewController *)child
4040
bottomTabOptions:(RNNBottomTabOptions *)bottomTabOptions {
41-
child.tabBarItem = [_tabCreator createTabBarItem:bottomTabOptions mergeItem:child.tabBarItem];
41+
UITabBarItem *updatedItem = [_tabCreator createTabBarItem:bottomTabOptions mergeItem:child.tabBarItem];
42+
if (updatedItem != child.tabBarItem) {
43+
child.tabBarItem = updatedItem;
44+
}
4245
}
4346

4447
@end

ios/RNNTabBarItemCreator.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@implementation RNNTabBarItemCreator
66

77
- (UITabBarItem *)createTabBarItem:(UITabBarItem *)mergeItem {
8-
return [UITabBarItem new];
8+
return mergeItem ?: [UITabBarItem new];
99
}
1010

1111
- (UITabBarItem *)createTabBarItem:(RNNBottomTabOptions *)bottomTabOptions

playground/ios/NavigationTests/BottomTabPresenterTest.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ - (void)testMergeOptions_shouldSetTabBarItemColorWithDefaultOptions {
5757
XCTAssertEqual(self.componentViewController.tabBarItem.title, @"title");
5858
}
5959

60-
- (void)testMergeOptions_shouldCreateNewTabBarItemInstance {
60+
- (void)testMergeOptions_shouldReuseExistingTabBarItemInstance {
6161
RNNNavigationOptions *defaultOptions = [RNNNavigationOptions emptyOptions];
6262
defaultOptions.bottomTab.selectedIconColor = [Color withColor:UIColor.greenColor];
6363
self.uut.defaultOptions = defaultOptions;
@@ -69,8 +69,8 @@ - (void)testMergeOptions_shouldCreateNewTabBarItemInstance {
6969
[self.uut mergeOptions:mergeOptions
7070
resolvedOptions:self.options
7171
child:self.componentViewController];
72-
UITabBarItem *newTabBarItem = self.componentViewController.tabBarItem;
73-
XCTAssertNotEqual(currentTabBarItem, newTabBarItem);
72+
UITabBarItem *updatedTabBarItem = self.componentViewController.tabBarItem;
73+
XCTAssertEqual(currentTabBarItem, updatedTabBarItem);
7474
}
7575

7676
@end

0 commit comments

Comments
 (0)