diff --git a/React/Views/RCTModalHostViewManager.m b/React/Views/RCTModalHostViewManager.m index 7fab70ef636368..4b9f9ad7267c8f 100644 --- a/React/Views/RCTModalHostViewManager.m +++ b/React/Views/RCTModalHostViewManager.m @@ -75,13 +75,15 @@ - (void)presentModalHostView:(RCTModalHostView *)modalHostView modalHostView.onShow(nil); } }; - if (_presentationBlock) { - _presentationBlock([modalHostView reactViewController], viewController, animated, completionBlock); - } else { - [[modalHostView reactViewController] presentViewController:viewController - animated:animated - completion:completionBlock]; - } + dispatch_async(dispatch_get_main_queue(), ^{ + if (self->_presentationBlock) { + self->_presentationBlock([modalHostView reactViewController], viewController, animated, completionBlock); + } else { + [[modalHostView reactViewController] presentViewController:viewController + animated:animated + completion:completionBlock]; + } + }); } - (void)dismissModalHostView:(RCTModalHostView *)modalHostView @@ -93,11 +95,13 @@ - (void)dismissModalHostView:(RCTModalHostView *)modalHostView [[self.bridge moduleForClass:[RCTModalManager class]] modalDismissed:modalHostView.identifier]; } }; - if (_dismissalBlock) { - _dismissalBlock([modalHostView reactViewController], viewController, animated, completionBlock); - } else { - [viewController.presentingViewController dismissViewControllerAnimated:animated completion:completionBlock]; - } + dispatch_async(dispatch_get_main_queue(), ^{ + if (self->_dismissalBlock) { + self->_dismissalBlock([modalHostView reactViewController], viewController, animated, completionBlock); + } else { + [viewController.presentingViewController dismissViewControllerAnimated:animated completion:completionBlock]; + } + }); } - (RCTShadowView *)shadowView