Skip to content

Instantly share code, notes, and snippets.

@madan712
Created February 9, 2022 16:02
Show Gist options
  • Save madan712/1fb83102c9a15f62057f4567df488b7e to your computer and use it in GitHub Desktop.
Save madan712/1fb83102c9a15f62057f4567df488b7e to your computer and use it in GitHub Desktop.
React native swipe gestures handler example
import GestureRecognizer, {swipeDirections} from 'react-native-swipe-gestures';
.
.
.
onSwipeUp(gestureState) {
this.setState({myText: 'You swiped up!'});
}
onSwipeDown(gestureState) {
this.setState({myText: 'You swiped down!'});
}
onSwipeLeft(gestureState) {
this.setState({myText: 'You swiped left!'});
}
onSwipeRight(gestureState) {
this.setState({myText: 'You swiped right!'});
}
.
.
render() {
return (
<GestureRecognizer
onSwipeUp={(state) => this.onSwipeUp(state)}
onSwipeDown={(state) => this.onSwipeDown(state)}
onSwipeLeft={(state) => this.onSwipeLeft(state)}
onSwipeRight={(state) => this.onSwipeRight(state)}
>
<Text>YOUR CONTENT</Text>
</GestureRecognizer>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment