From cc30e2b57cf4f9ded1b0a178d4d28f4ef6fa8308 Mon Sep 17 00:00:00 2001 From: DougBanksPersonal Date: Fri, 22 Jan 2016 17:26:17 -0800 Subject: [PATCH] Update RCTNavigator.m Summary: I am using ReactNative in a hybrid App. We have a setup like so: Native Navigation Controller Native Tab Controller Native View Controller wrapping React React Navigation Controller React View Controller 1 React View Controller 2 Native View Controller 2. When I pop Native View Controller 2 off the Navigation stack, I get a seg fault on this line: NSUInteger indexOfFrom = [_currentViews indexOfObject:fromController.navItem]; I believe what's happening: Your code is listening to Nav Controller transitions, assuming that they are all from React Native Nav Controllers. You are catching this one instead, which is actually a Native Nav Controller transition. You start trying to access the pushed/popped view controllers as if they were react native view controllers. In this case, the view controllers are not react native -> no navItem field -> seg fault. Solution: if we are catching this transition but it isn't from our react native nav controller, just Closes https://github.com/facebook/react-native/pull/5495 Reviewed By: svcscm Differential Revision: D2857473 Pulled By: nicklockwood fb-gh-sync-id: cc7f0a16e2e0cea56ca9e49bcb87db4ebd3a0905 --- React/Views/RCTNavigator.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/React/Views/RCTNavigator.m b/React/Views/RCTNavigator.m index 460a5fc6e..10e415ab0 100644 --- a/React/Views/RCTNavigator.m +++ b/React/Views/RCTNavigator.m @@ -361,6 +361,13 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) (RCTWrapperViewController *)[context viewControllerForKey:UITransitionContextFromViewControllerKey]; RCTWrapperViewController *toController = (RCTWrapperViewController *)[context viewControllerForKey:UITransitionContextToViewControllerKey]; + + // This may be triggered by a navigation controller unrelated to me: if so, ignore. + if (fromController.navigationController != _navigationController || + toController.navigationController != _navigationController) { + return; + } + NSUInteger indexOfFrom = [_currentViews indexOfObject:fromController.navItem]; NSUInteger indexOfTo = [_currentViews indexOfObject:toController.navItem]; CGFloat destination = indexOfFrom < indexOfTo ? 1.0 : -1.0;