Skip to content

Commit 9d5dca6

Browse files
committed
fix(ios, afterInitialTab): ensure initial tab mounts before other tabs.
Updated `BottomTabsAfterInitialTabAttacher` to asynchronously attach other tabs after the initial tab's `componentDidMount` is called.
1 parent 11efb13 commit 9d5dca6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/ios/BottomTabsAfterInitialTabAttacher.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ - (void)attach:(UITabBarController *)bottomTabsController {
77
[bottomTabsController.selectedViewController setReactViewReadyCallback:^{
88
[bottomTabsController readyForPresentation];
99
for (UIViewController *viewController in bottomTabsController.deselectedViewControllers) {
10+
dispatch_async(dispatch_get_main_queue(), ^{
1011
[viewController render];
12+
});
1113
}
1214
}];
1315

playground/ios/NavigationTests/RNNCommandsHandlerTest.m

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,21 @@ - (void)testSetRoot_withBottomTabsAttachModeAfterInitialTab {
554554
}];
555555

556556
[self waitForExpectationsWithTimeout:10 handler:nil];
557-
XCTAssertTrue(_vc1.isViewLoaded);
558-
XCTAssertTrue(_vc2.isViewLoaded);
557+
558+
XCTAssertTrue(self->_vc1.isViewLoaded);
559+
560+
// Make sure the view is not loaded until the next main run loop.
561+
XCTAssertFalse(self->_vc2.isViewLoaded);
562+
563+
564+
// Wait for the next main run-loop.
565+
XCTestExpectation *viewLoadedExpectation = [self expectationWithDescription:@"Wait for _vc2.isViewLoaded"];
566+
dispatch_async(dispatch_get_main_queue(), ^{
567+
XCTAssertTrue(self->_vc2.isViewLoaded);
568+
[viewLoadedExpectation fulfill];
569+
});
570+
571+
[self waitForExpectationsWithTimeout:1 handler:nil];
559572
}
560573

561574
- (void)testSetRoot_withAnimation {

0 commit comments

Comments
 (0)