From 8ec672204d5dee2b967cac08adf03c082e36ad79 Mon Sep 17 00:00:00 2001 From: Zhi Zhou Date: Tue, 20 Aug 2024 10:04:47 -0700 Subject: [PATCH] fix: iOS crash occurring when navigating to a new app screen with a displaying modal (#45313) Summary: Our app is using the react-native v0.74.2 with the `react-navigation` lib for screen navigation, we're facing an issue in the built iOS app that when we try to navigate to a new app screen with the `react-navigation`'s `reset` or `replace` method and meanwhile there's a react native modal displaying, then the iOS app always crashes. I saw there is already a relevant [PR](https://github.com/facebook/react-native/pull/38491) and discussion targeting this issue, but I still think it would be better if this kind of crash can be suppressed in the framework level, currently I guess it's common in the iOS apps based on react native. ## Changelog: [IOS] [FIXED] - app crash happening when navigate to a new app screen with a displaying modal Pull Request resolved: https://github.com/facebook/react-native/pull/45313 Test Plan: More issue details and the reproduction steps can be found in this [PR](https://github.com/facebook/react-native/pull/38491) :) Reviewed By: christophpurrer Differential Revision: D61537167 Pulled By: cipolleschi fbshipit-source-id: 3c0474d794b4216ebc073dd6558d2b6ae27492d2 --- packages/react-native/React/Views/RCTModalHostView.m | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-native/React/Views/RCTModalHostView.m b/packages/react-native/React/Views/RCTModalHostView.m index dfde4ae47ab137..939f32dbf283d2 100644 --- a/packages/react-native/React/Views/RCTModalHostView.m +++ b/packages/react-native/React/Views/RCTModalHostView.m @@ -119,6 +119,7 @@ - (void)dismissModalViewController if (_isPresented) { [_delegate dismissModalHostView:self withViewController:_modalViewController animated:[self hasAnimationType]]; _isPresented = NO; + [self setVisible:NO]; } }