Last active
September 19, 2025 20:53
-
-
Save scarlac/3c29b40484ae629d1cdf86e721c71c63 to your computer and use it in GitHub Desktop.
Fixes Switch not being clickable/wrong size: https://github.com/facebook/react-native/issues/53537
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/node_modules/react-native/Libraries/Components/Switch/Switch.js b/node_modules/react-native/Libraries/Components/Switch/Switch.js | |
| index d3b88af..436a4bf 100644 | |
| --- a/node_modules/react-native/Libraries/Components/Switch/Switch.js | |
| +++ b/node_modules/react-native/Libraries/Components/Switch/Switch.js | |
| @@ -260,11 +260,14 @@ const Switch: component( | |
| /> | |
| ); | |
| } else { | |
| + const switchSizeGteIos26 = { width: 63, height: 28 }; | |
| + const switchSizeLteIos18 = { width: 51, height: 31 }; | |
| + const switchSize = Platform.OS === 'ios' && parseInt(Platform.Version) >= 26 ? switchSizeGteIos26 : switchSizeLteIos18; | |
| const platformProps = { | |
| disabled, | |
| onTintColor: trackColorForTrue, | |
| style: StyleSheet.compose( | |
| - {alignSelf: 'flex-start' as const}, | |
| + {alignSelf: 'flex-start' as const, ...switchSize}, | |
| StyleSheet.compose( | |
| style, | |
| ios_backgroundColor == null | |
| diff --git a/node_modules/react-native/React/Views/RCTSwitch.m b/node_modules/react-native/React/Views/RCTSwitch.m | |
| index 0cce9e1..d36ab53 100644 | |
| --- a/node_modules/react-native/React/Views/RCTSwitch.m | |
| +++ b/node_modules/react-native/React/Views/RCTSwitch.m | |
| @@ -14,7 +14,7 @@ | |
| - (void)setOn:(BOOL)on animated:(BOOL)animated | |
| { | |
| _wasOn = on; | |
| - [super setOn:on animated:animated]; | |
| + [super setOn:on animated:YES]; | |
| } | |
| @end | |
| diff --git a/node_modules/react-native/React/Views/RCTSwitchManager.m b/node_modules/react-native/React/Views/RCTSwitchManager.m | |
| index b04b51f..eb06e2a 100644 | |
| --- a/node_modules/react-native/React/Views/RCTSwitchManager.m | |
| +++ b/node_modules/react-native/React/Views/RCTSwitchManager.m | |
| @@ -39,7 +39,7 @@ RCT_EXPORT_METHOD(setValue : (nonnull NSNumber *)viewTag toValue : (BOOL)value) | |
| UIView *view = viewRegistry[viewTag]; | |
| if ([view isKindOfClass:[UISwitch class]]) { | |
| - [(UISwitch *)view setOn:value animated:NO]; | |
| + [(UISwitch *)view setOn:value animated:YES]; | |
| } else { | |
| RCTLogError(@"view type must be UISwitch"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment