Skip to content

Commit 8a8df22

Browse files
committed
change Incubator TouchableOpacity props to be optional
1 parent 0423e9f commit 8a8df22

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

generatedTypes/incubator/TouchableOpacity.d.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,38 @@ declare type TouchableOpacityPropTypes = {
44
/**
55
* Background color
66
*/
7-
backgroundColor: string;
7+
backgroundColor?: string;
88
/**
99
* Background color when actively pressing the touchable
1010
*/
11-
feedbackColor: string;
11+
feedbackColor?: string;
1212
/**
1313
* Opacity value when actively pressing the touchable
1414
*/
15-
activeOpacity: number;
15+
activeOpacity?: number;
1616
/**
1717
* Scale value when actively pressing the touchable
1818
*/
19-
activeScale: number;
19+
activeScale?: number;
2020
/**
2121
* Callback for when tapping the touchable
2222
*/
23-
onPress: (props: any) => void;
23+
onPress?: (props: any) => void;
2424
/**
2525
* Callback for when long pressing the touchable
2626
*/
27-
onLongPress: (props: any) => void;
27+
onLongPress?: (props: any) => void;
2828
/**
2929
* Pass controlled pressState to track gesture state changes
3030
*/
31-
pressState: object;
31+
pressState?: object;
3232
/**
3333
* If true, disable all interactions for this component.
3434
*/
35-
disabled: boolean;
35+
disabled?: boolean;
36+
/**
37+
* Pass custom style
38+
*/
3639
style: ViewStyle;
3740
};
3841
declare const _default: React.ComponentType<TouchableOpacityPropTypes>;

src/incubator/TouchableOpacity.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,38 @@ type TouchableOpacityPropTypes = {
3030
/**
3131
* Background color
3232
*/
33-
backgroundColor: string;
33+
backgroundColor?: string;
3434
/**
3535
* Background color when actively pressing the touchable
3636
*/
37-
feedbackColor: string;
37+
feedbackColor?: string;
3838
/**
3939
* Opacity value when actively pressing the touchable
4040
*/
41-
activeOpacity: number;
41+
activeOpacity?: number;
4242
/**
4343
* Scale value when actively pressing the touchable
4444
*/
45-
activeScale: number;
45+
activeScale?: number;
4646
/**
4747
* Callback for when tapping the touchable
4848
*/
49-
onPress: (props: any) => void;
49+
onPress?: (props: any) => void;
5050
/**
5151
* Callback for when long pressing the touchable
5252
*/
53-
onLongPress: (props: any) => void;
53+
onLongPress?: (props: any) => void;
5454
/**
5555
* Pass controlled pressState to track gesture state changes
5656
*/
57-
pressState: object;
57+
pressState?: object;
5858
/**
5959
* If true, disable all interactions for this component.
6060
*/
61-
disabled: boolean;
62-
61+
disabled?: boolean;
62+
/**
63+
* Pass custom style
64+
*/
6365
style: ViewStyle;
6466
};
6567

@@ -86,8 +88,8 @@ class TouchableOpacity extends PureComponent<TouchableOpacityPropTypes & BaseCom
8688
isAnimating = new Value(0);
8789
clock = new Clock();
8890

89-
_scale = runTiming(this.clock, this.pressState, this.props.activeScale, 1);
90-
_opacity = runTiming(this.clock, this.pressState, this.props.activeOpacity, 1);
91+
_scale = runTiming(this.clock, this.pressState, this.props.activeScale || 1, 1);
92+
_opacity = runTiming(this.clock, this.pressState, this.props.activeOpacity || 0.2, 1);
9193
_color = cond(eq(this.pressState, State.BEGAN),
9294
processColor(this.props.feedbackColor || this.backgroundColor),
9395
processColor(this.backgroundColor));
@@ -130,7 +132,7 @@ class TouchableOpacity extends PureComponent<TouchableOpacityPropTypes & BaseCom
130132
};
131133

132134
render() {
133-
const {modifiers, style, onPress, onLongPress, disabled, forwardedRef, ...others} = this.props;
135+
const {modifiers, style, onPress = _.noop, onLongPress, disabled, forwardedRef, ...others} = this.props;
134136
const {borderRadius, paddings, margins, alignments, flexStyle, backgroundColor} = modifiers;
135137

136138
return (

0 commit comments

Comments
 (0)