Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/react-native/React/CoreModules/RCTDeviceInfo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ @implementation RCTDeviceInfo {
NSDictionary *_currentInterfaceDimensions;
BOOL _isFullscreen;
std::atomic<BOOL> _invalidated;
__weak UIWindow *_keyWindow;
}

static NSString *const kFrameKeyPath = @"frame";
Expand All @@ -40,7 +41,8 @@ @implementation RCTDeviceInfo {
- (instancetype)init
{
if (self = [super init]) {
[RCTKeyWindow() addObserver:self forKeyPath:kFrameKeyPath options:NSKeyValueObservingOptionNew context:nil];
_keyWindow = RCTKeyWindow();
[_keyWindow addObserver:self forKeyPath:kFrameKeyPath options:NSKeyValueObservingOptionNew context:nil];
}
return self;
}
Expand Down Expand Up @@ -131,7 +133,7 @@ - (void)_cleanupObservers

[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTBridgeWillInvalidateModulesNotification object:nil];

[RCTKeyWindow() removeObserver:self forKeyPath:kFrameKeyPath];
[_keyWindow removeObserver:self forKeyPath:kFrameKeyPath];

#if TARGET_OS_IOS
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
Expand Down
Loading