Skip to content

Commit bf3ddd3

Browse files
authored
[iOS] Prevent crash when setting cursor style (#3097)
## Description If you try to set `cursor` style in our buttons on `iOS` you'll get `unrecognized selector` error. This PR sets `cursor` value to be undefined on `iOS`, so apps no longer crash. Fixes #3081 ## Test plan <details> <summary>Tested on the following code:</summary> ```tsx import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { RectButton } from 'react-native-gesture-handler'; export default function EmptyExample() { return ( <View style={styles.container}> <Text>Hello World!</Text> <RectButton style={{ width: 100, height: 20, backgroundColor: 'blue', cursor: 'grab', }} /> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, }); ``` </details>
1 parent 7b23464 commit bf3ddd3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/components/GestureButtons.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ class InnerBaseButton extends React.Component<BaseButtonWithRefProps> {
120120
};
121121

122122
render() {
123-
const { rippleColor, ...rest } = this.props;
123+
const { rippleColor, style, ...rest } = this.props;
124124

125125
return (
126126
<RawButton
127127
ref={this.props.innerRef}
128128
rippleColor={processColor(rippleColor)}
129+
style={[style, Platform.OS === 'ios' && { cursor: undefined }]}
129130
{...rest}
130131
onGestureEvent={this.onGestureEvent}
131132
onHandlerStateChange={this.onHandlerStateChange}

0 commit comments

Comments
 (0)