@@ -63,7 +63,11 @@ class TouchableOpacity extends PureComponent {
63
63
/**
64
64
* Pass controlled pressState to track gesture state changes
65
65
*/
66
- pressState : PropTypes . object
66
+ pressState : PropTypes . object ,
67
+ /**
68
+ * If true, disable all interactions for this component.
69
+ */
70
+ disabled : PropTypes . bool
67
71
} ;
68
72
69
73
static defaultProps = {
@@ -124,11 +128,16 @@ class TouchableOpacity extends PureComponent {
124
128
} ;
125
129
126
130
render ( ) {
127
- const { modifiers, style, onPress, onLongPress, forwardedRef, ...others } = this . props ;
131
+ const { modifiers, style, onPress, onLongPress, disabled , forwardedRef, ...others } = this . props ;
128
132
const { borderRadius, paddings, margins, alignments, flexStyle, backgroundColor} = modifiers ;
129
133
130
134
return (
131
- < TapGestureHandler onHandlerStateChange = { this . onStateChange } shouldCancelWhenOutside ref = { forwardedRef } >
135
+ < TapGestureHandler
136
+ onHandlerStateChange = { this . onStateChange }
137
+ shouldCancelWhenOutside
138
+ ref = { forwardedRef }
139
+ enabled = { ! disabled }
140
+ >
132
141
< Reanimated . View
133
142
{ ...others }
134
143
style = { [
@@ -154,9 +163,11 @@ class TouchableOpacity extends PureComponent {
154
163
] ) ;
155
164
} }
156
165
</ Code >
157
- { onLongPress && < LongPressGestureHandler onHandlerStateChange = { this . onLongPress } >
158
- < Reanimated . View style = { StyleSheet . absoluteFillObject } />
159
- </ LongPressGestureHandler > }
166
+ { onLongPress && (
167
+ < LongPressGestureHandler onHandlerStateChange = { this . onLongPress } enabled = { ! disabled } >
168
+ < Reanimated . View style = { StyleSheet . absoluteFillObject } />
169
+ </ LongPressGestureHandler >
170
+ ) }
160
171
</ Reanimated . View >
161
172
</ TapGestureHandler >
162
173
) ;
0 commit comments