diff --git a/packages/react-native/React/Base/RCTUtils.mm b/packages/react-native/React/Base/RCTUtils.mm index d2bf9ded0d1..6d89ba62303 100644 --- a/packages/react-native/React/Base/RCTUtils.mm +++ b/packages/react-native/React/Base/RCTUtils.mm @@ -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; } diff --git a/packages/react-native/ReactCommon/react/renderer/components/switch/iosswitch/react/renderer/components/switch/IOSSwitchShadowNode.mm b/packages/react-native/ReactCommon/react/renderer/components/switch/iosswitch/react/renderer/components/switch/IOSSwitchShadowNode.mm index b38b0b0509c..d1981f17c06 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/switch/iosswitch/react/renderer/components/switch/IOSSwitchShadowNode.mm +++ b/packages/react-native/ReactCommon/react/renderer/components/switch/iosswitch/react/renderer/components/switch/IOSSwitchShadowNode.mm @@ -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