Skip to content

Commit 43e545b

Browse files
committed
fix: implement old arch, add warnings, fix types
1 parent 247c52f commit 43e545b

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

packages/react-native/Libraries/Modal/Modal.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ export type ModalBaseProps = {
8686
*/
8787
visible?: ?boolean,
8888
/**
89-
* The `onRequestClose` callback is called when the user taps the hardware back button on Android or the menu button on Apple TV.
89+
* The `onRequestClose` callback is called when the user taps the hardware back button on Android, dismisses the sheet using a gesture on iOS or the menu button on Apple TV.
9090
*
91-
* This is required on Apple TV and Android.
91+
* This is required on iOS and Android.
9292
*/
9393
// onRequestClose?: (event: NativeSyntheticEvent<any>) => void;
9494
onRequestClose?: ?DirectEventHandler<null>,
@@ -192,6 +192,12 @@ function confirmProps(props: ModalProps) {
192192
'Modal with translucent navigation bar and without translucent status bar is not supported.',
193193
);
194194
}
195+
196+
if (!props.onRequestClose) {
197+
console.warn(
198+
'Modal requires the onRequestClose prop. This is necessary to prevent state corruption.',
199+
);
200+
}
195201
}
196202
}
197203

packages/react-native/React/Views/RCTModalHostView.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ - (void)presentationControllerDidAttemptToDismiss:(UIPresentationController *)co
7070
}
7171
}
7272

73+
- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController {
74+
if (_onRequestClose != nil) {
75+
_onRequestClose(nil);
76+
}
77+
}
78+
7379
- (void)notifyForOrientationChange
7480
{
7581
if (!_onOrientationChange) {

packages/react-native/React/Views/RCTModalHostViewController.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ - (instancetype)init
2222
return nil;
2323
}
2424

25-
self.modalInPresentation = YES;
26-
2725
_preferredStatusBarStyle = [RCTUIStatusBarManager() statusBarStyle];
2826
_preferredStatusBarHidden = [RCTUIStatusBarManager() isStatusBarHidden];
2927

0 commit comments

Comments
 (0)