fix crash for feature flag

This commit is contained in:
Riccardo Cipolleschi
2025-08-21 13:12:21 +01:00
parent 8f26b77af1
commit f62e981b5e
2 changed files with 6 additions and 2 deletions
+3 -1
View File
@@ -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;
}
@@ -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