@@ -30,36 +30,38 @@ type TouchableOpacityPropTypes = {
30
30
/**
31
31
* Background color
32
32
*/
33
- backgroundColor : string ;
33
+ backgroundColor ? : string ;
34
34
/**
35
35
* Background color when actively pressing the touchable
36
36
*/
37
- feedbackColor : string ;
37
+ feedbackColor ? : string ;
38
38
/**
39
39
* Opacity value when actively pressing the touchable
40
40
*/
41
- activeOpacity : number ;
41
+ activeOpacity ? : number ;
42
42
/**
43
43
* Scale value when actively pressing the touchable
44
44
*/
45
- activeScale : number ;
45
+ activeScale ? : number ;
46
46
/**
47
47
* Callback for when tapping the touchable
48
48
*/
49
- onPress : ( props : any ) => void ;
49
+ onPress ? : ( props : any ) => void ;
50
50
/**
51
51
* Callback for when long pressing the touchable
52
52
*/
53
- onLongPress : ( props : any ) => void ;
53
+ onLongPress ? : ( props : any ) => void ;
54
54
/**
55
55
* Pass controlled pressState to track gesture state changes
56
56
*/
57
- pressState : object ;
57
+ pressState ? : object ;
58
58
/**
59
59
* If true, disable all interactions for this component.
60
60
*/
61
- disabled : boolean ;
62
-
61
+ disabled ?: boolean ;
62
+ /**
63
+ * Pass custom style
64
+ */
63
65
style : ViewStyle ;
64
66
} ;
65
67
@@ -86,8 +88,8 @@ class TouchableOpacity extends PureComponent<TouchableOpacityPropTypes & BaseCom
86
88
isAnimating = new Value ( 0 ) ;
87
89
clock = new Clock ( ) ;
88
90
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 ) ;
91
93
_color = cond ( eq ( this . pressState , State . BEGAN ) ,
92
94
processColor ( this . props . feedbackColor || this . backgroundColor ) ,
93
95
processColor ( this . backgroundColor ) ) ;
@@ -130,7 +132,7 @@ class TouchableOpacity extends PureComponent<TouchableOpacityPropTypes & BaseCom
130
132
} ;
131
133
132
134
render ( ) {
133
- const { modifiers, style, onPress, onLongPress, disabled, forwardedRef, ...others } = this . props ;
135
+ const { modifiers, style, onPress = _ . noop , onLongPress, disabled, forwardedRef, ...others } = this . props ;
134
136
const { borderRadius, paddings, margins, alignments, flexStyle, backgroundColor} = modifiers ;
135
137
136
138
return (
0 commit comments