mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fix crash for feature flag
This commit is contained in:
@@ -431,7 +431,9 @@ CGSize RCTSwitchSize(void)
|
||||
static CGSize rctSwitchSize;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
rctSwitchSize = [UISwitch new].intrinsicContentSize;
|
||||
RCTUnsafeExecuteOnMainQueueSync(^{
|
||||
rctSwitchSize = [UISwitch new].intrinsicContentSize;
|
||||
});
|
||||
});
|
||||
return rctSwitchSize;
|
||||
}
|
||||
|
||||
+3
-1
@@ -20,7 +20,9 @@ Size SwitchShadowNode::measureContent(
|
||||
const LayoutConstraints & /*layoutConstraints*/) const
|
||||
{
|
||||
CGSize uiSwitchSize = RCTSwitchSize();
|
||||
return {.width = uiSwitchSize.width, .height = uiSwitchSize.height};
|
||||
// Apple has some error when returning the width of the component and it doesn't
|
||||
// account for the borders.
|
||||
return {.width = uiSwitchSize.width + 2, .height = uiSwitchSize.height};
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
|
||||
Reference in New Issue
Block a user