Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e853722

Browse files
sherginfacebook-github-bot
authored andcommittedOct 1, 2020
A couple of checks for corner cases in RCTGetDimensions and RCTExportedDimensions
Summary: We need this checks to make the results of those function more reliable. Reviewed By: sammy-SC Differential Revision: D24038911 fbshipit-source-id: 3b54fe3056c9508cde84ea157beebea57e7e49b6
1 parent 9a2a4ba commit e853722

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
 

‎React/CoreModules/RCTDeviceInfo.mm

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ static BOOL RCTIsIPhoneX()
9393
static NSDictionary *RCTExportedDimensions(RCTBridge *bridge)
9494
{
9595
RCTAssertMainQueue();
96-
RCTDimensions dimensions = RCTGetDimensions(bridge.accessibilityManager.multiplier);
96+
RCTAssert(bridge, @"Bridge must not be `nil`.");
97+
RCTDimensions dimensions = RCTGetDimensions(bridge.accessibilityManager.multiplier ?: 1.0);
9798
__typeof(dimensions.window) window = dimensions.window;
9899
NSDictionary<NSString *, NSNumber *> *dimsWindow = @{
99100
@"width" : @(window.width),

‎React/UIUtils/RCTUIUtils.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ RCTDimensions RCTGetDimensions(CGFloat fontScale)
1616

1717
UIView *mainWindow;
1818
mainWindow = RCTKeyWindow();
19-
CGSize windowSize = mainWindow.bounds.size;
19+
// We fallback to screen size if a key window is not found.
20+
CGSize windowSize = mainWindow ? mainWindow.bounds.size : screenSize;
2021

2122
RCTDimensions result;
2223
typeof(result.screen) dimsScreen = {

0 commit comments

Comments
 (0)
Please sign in to comment.