Skip to content

Commit 3b72817

Browse files
Remove extra view in GenericTouchable
1 parent b776a81 commit 3b72817

3 files changed

Lines changed: 28 additions & 23 deletions

File tree

packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
import type { NativeViewGestureHandlerPayload } from '../../handlers/GestureHandlerEventPayload';
1313
import type { GenericTouchableProps } from './GenericTouchableProps';
1414

15+
const AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);
16+
1517
/**
1618
* Each touchable is a states' machine which preforms transitions.
1719
* On very beginning (and on the very end or recognition) touchable is
@@ -29,6 +31,11 @@ type TouchableState = (typeof TOUCHABLE_STATE)[keyof typeof TOUCHABLE_STATE];
2931

3032
interface InternalProps {
3133
onStateChange?: (oldState: TouchableState, newState: TouchableState) => void;
34+
borderless?: boolean;
35+
rippleColor?: string | number | null;
36+
rippleRadius?: number | null;
37+
foreground?: boolean;
38+
exclusive?: boolean;
3239
}
3340

3441
// TODO: maybe can be better
@@ -45,10 +52,8 @@ export default class GenericTouchable extends Component<
4552
> {
4653
static defaultProps = {
4754
delayLongPress: 600,
48-
extraButtonProps: {
49-
rippleColor: 'transparent',
50-
exclusive: true,
51-
},
55+
rippleColor: 'transparent',
56+
exclusive: true,
5257
};
5358

5459
// Timeout handlers
@@ -248,11 +253,20 @@ export default class GenericTouchable extends Component<
248253
onAccessibilityAction: this.props.onAccessibilityAction,
249254
nativeID: this.props.nativeID,
250255
onLayout: this.props.onLayout,
256+
borderless: this.props.borderless,
257+
rippleColor: this.props.rippleColor,
258+
exclusive: this.props.exclusive,
259+
rippleRadius: this.props.rippleRadius,
260+
foreground: this.props.foreground,
261+
// rn-web
262+
className: (this.props as any).className,
263+
href: (this.props as any).href,
264+
onClick: (this.props as any).onClick,
265+
onMouseEnter: (this.props as any).onMouseEnter,
251266
};
252267

253268
return (
254-
<BaseButton
255-
style={this.props.containerStyle}
269+
<AnimatedBaseButton
256270
onHandlerStateChange={
257271
// TODO: not sure if it can be undefined instead of null
258272
this.props.disabled ? undefined : this.onHandlerStateChange
@@ -265,11 +279,10 @@ export default class GenericTouchable extends Component<
265279
testID={this.props.testID}
266280
touchSoundDisabled={this.props.touchSoundDisabled ?? false}
267281
enabled={!this.props.disabled}
268-
{...this.props.extraButtonProps}>
269-
<Animated.View {...coreProps} style={this.props.style}>
270-
{this.props.children}
271-
</Animated.View>
272-
</BaseButton>
282+
{...coreProps}
283+
style={this.props.style}>
284+
{this.props.children}
285+
</AnimatedBaseButton>
273286
);
274287
}
275288
}

packages/react-native-gesture-handler/src/components/touchables/GenericTouchableProps.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import type {
2-
StyleProp,
3-
ViewStyle,
4-
TouchableWithoutFeedbackProps,
5-
Insets,
6-
} from 'react-native';
1+
import type { TouchableWithoutFeedbackProps, Insets } from 'react-native';
72
import type { UserSelect } from '../../handlers/gestureHandlerCommon';
83
import { ExtraButtonProps } from './ExtraButtonProps';
94

@@ -21,7 +16,6 @@ export interface GenericTouchableProps
2116
shouldActivateOnStart?: boolean;
2217
disallowInterruption?: boolean;
2318

24-
containerStyle?: StyleProp<ViewStyle>;
2519
hitSlop?: Insets | number;
2620
userSelect?: UserSelect;
2721
extraButtonProps?: ExtraButtonProps;

packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedback.android.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ export default class TouchableNativeFeedback extends Component<TouchableNativeFe
1919
static defaultProps = {
2020
...GenericTouchable.defaultProps,
2121
useForeground: true,
22-
extraButtonProps: {
23-
// Disable hiding ripple on Android
24-
rippleColor: null,
25-
},
22+
// Disable hiding ripple on Android
23+
rippleColor: null,
2624
};
2725

2826
// Could be taken as RNTouchableNativeFeedback.SelectableBackground etc. but the API may change
@@ -76,7 +74,7 @@ export default class TouchableNativeFeedback extends Component<TouchableNativeFe
7674
<GenericTouchable
7775
{...rest}
7876
style={style}
79-
extraButtonProps={this.getExtraButtonProps()}
77+
{...this.getExtraButtonProps()}
8078
/>
8179
);
8280
}

0 commit comments

Comments
 (0)