onPress, onClick, onSelect is missing
mayurkothule opened this issue · 1 comments
mayurkothule commented
onPress event missing.
Is there any way to get onPress/onClick callback from child component of <GestureRecognizer/>
e.g
<GestureRecognizer
onSwipeLeft={state => this.onSwipeLeft(state)}
onSwipeRight={state => this.onSwipeRight(state)}
config={config}
>
<TouchableOpacity onPress={this.onViewClick.bind(this)}>
<Text >{this.props.text}</Text>
</TouchableOpacity>
</GestureRecognizer>
OR
<GestureRecognizer
onSwipeLeft={state => this.onSwipeLeft(state)}
onSwipeRight={state => this.onSwipeRight(state)}
onPress={this.onViewClick.bind(this)}
config={config}
>
<Text >{this.props.text}</Text>
</GestureRecognizer>
paulenokels commented
A temporary work around to handle click/press events
- Open
node_modules/react-native-swipe-gestures/index.js
- Edit the method
_shouldSetPanResponder
to look like this
_handleShouldSetPanResponder(evt, gestureState) {
if (this._gestureIsClick(gestureState) && this.props.onPressGesture) {
return this.props.onPressGesture();
}
return (
evt.nativeEvent.touches.length === 1 &&
!this._gestureIsClick(gestureState)
);
}
- Update your component where you used GestureRecognizer to look like this
` <GestureRecognizer
onPressGesture={() => {/* handle your press/click event here */}}
...
`