Skip to content

Commit

Permalink
fix: patch react-native modal
Browse files Browse the repository at this point in the history
  • Loading branch information
wood1986 committed Dec 22, 2022
1 parent 4d681a7 commit 86e7bc1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .yarn/patches/react-native-npm-0.70.6-94c39d80fa.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
diff --git a/React/Views/RCTModalHostViewManager.m b/React/Views/RCTModalHostViewManager.m
index 7fab70ef636368b45ba250f6f304df5203d6f2d8..4b9f9ad7267c8f3ed04e9ab3007c193d423df91a 100644
--- a/React/Views/RCTModalHostViewManager.m
+++ b/React/Views/RCTModalHostViewManager.m
@@ -75,13 +75,15 @@ RCT_EXPORT_MODULE()
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 @@ RCT_EXPORT_MODULE()
[[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
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@
"node"
]
},
"packageManager": "yarn@3.3.1"
"packageManager": "yarn@3.3.1",
"resolutions": {
"react-native@0.70.6": "patch:react-native@npm%3A0.70.6#./.yarn/patches/react-native-npm-0.70.6-94c39d80fa.patch"
}
}

0 comments on commit 86e7bc1

Please sign in to comment.