Created
February 9, 2022 16:02
-
-
Save madan712/1fb83102c9a15f62057f4567df488b7e to your computer and use it in GitHub Desktop.
React native swipe gestures handler example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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