Skip to content

Commit

Permalink
enchancement(handler): handle nil on alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
admirsaheta committed Dec 20, 2022
1 parent 9f78517 commit 79f32b4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion React/CoreModules/RCTAlertController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@ @implementation RCTAlertController
- (UIWindow *)alertWindow
{
if (_alertWindow == nil) {
_alertWindow = [[UIWindow alloc] initWithFrame:RCTSharedApplication().keyWindow.bounds];
UIWindow *keyWindow = RCTSharedApplication().keyWindow;
if (keyWindow) {
_alertWindow = [[UIWindow alloc] initWithFrame:keyWindow.bounds];
_alertWindow.rootViewController = [UIViewController new];
_alertWindow.windowLevel = UIWindowLevelAlert + 1;
} else {
// keyWindow is nil, so we cannot create and initialize _alertWindow
NSLog(@"Unable to create alert window: keyWindow is nil");
}
}

return _alertWindow;
}

Expand Down

0 comments on commit 79f32b4

Please sign in to comment.