Skip to content

Commit

Permalink
fix(ios): rapid taps on the navigation tabs (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
jixt authored Mar 14, 2022
1 parent 08d5c78 commit 27e8003
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ios/ReactNativePageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,17 @@ - (void)setReactViewControllers:(NSInteger)index
if (animated == YES) {
self.animating = YES;
}

//
// If 'controller' is the current visible controller and the 'animated' flag is set to YES,
// then 'setViewControllers' is called without invoking the completion handler. This can block the navigation from working.
// So we need to check if that would be the case, and if so, we will not perform animation.
//
BOOL canAnimate = (controller != [[self.reactPageViewController viewControllers] firstObject] );

[self.reactPageViewController setViewControllers:@[controller]
direction:direction
animated:animated
animated:canAnimate?animated:NO
completion:^(BOOL finished) {
__strong typeof(self) strongSelf = weakSelf;
strongSelf.currentIndex = index;
Expand Down

0 comments on commit 27e8003

Please sign in to comment.