Created
July 24, 2018 11:18
-
-
Save marsinearth/bbc7dfa17c78784669cd08f9337bd8f2 to your computer and use it in GitHub Desktop.
debounce예제
This file contains 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 React, { PureComponent } from 'react' | |
import { TouchableOpacity, View, Text } from 'react-native' | |
import _debounce from 'lodash/debounce' | |
const DELAY = 400 | |
class HomeButton extends PureComponent { | |
onDebounce = _debounce(this.onPress, DELAY) | |
onPress = () => { | |
const { navigation } = this.props | |
navigation.navigate({ routeName: 'page1' }) | |
} | |
render() { | |
return ( | |
<TouchableOpacity onPress={this.onDebounce}> | |
<View> | |
<Text>to Page 1</Text> | |
</View> | |
</TouchableOpacity> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple and helpful snippet! Thanks a lot.