Skip to content

Commit

Permalink
[iOS] Prevent crash when setting cursor style (#3097)
Browse files Browse the repository at this point in the history
## 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>
  • Loading branch information
m-bert authored Sep 16, 2024
1 parent 7b23464 commit bf3ddd3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/GestureButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,13 @@ class InnerBaseButton extends React.Component<BaseButtonWithRefProps> {
};

render() {
const { rippleColor, ...rest } = this.props;
const { rippleColor, style, ...rest } = this.props;

return (
<RawButton
ref={this.props.innerRef}
rippleColor={processColor(rippleColor)}
style={[style, Platform.OS === 'ios' && { cursor: undefined }]}
{...rest}
onGestureEvent={this.onGestureEvent}
onHandlerStateChange={this.onHandlerStateChange}
Expand Down

0 comments on commit bf3ddd3

Please sign in to comment.