From 96d13b663bd9717c2cc37044208799fc39e5e8b2 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Fri, 28 Apr 2017 03:26:30 -0700 Subject: [PATCH] Avoid presenting on view controller that's being dismissed Summary: Mitigates the issue in https://github.com/facebook/react-native/issues/10471, by not trying to present a modal or alert view if the presenting view controller is already being dismissed. Reviewed By: shergin Differential Revision: D4962169 fbshipit-source-id: 593e3f21096458651d16677a3e030552f809bf02 --- React/Base/RCTUtils.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/React/Base/RCTUtils.m b/React/Base/RCTUtils.m index c00bb283d..ab49299d3 100644 --- a/React/Base/RCTUtils.m +++ b/React/Base/RCTUtils.m @@ -481,9 +481,10 @@ UIViewController *__nullable RCTPresentedViewController(void) } UIViewController *controller = RCTKeyWindow().rootViewController; - - while (controller.presentedViewController) { - controller = controller.presentedViewController; + UIViewController *presentedController = controller.presentedViewController; + while (presentedController && ![presentedController isBeingDismissed]) { + controller = presentedController; + presentedController = controller.presentedViewController; } return controller;