Skip to content

Instantly share code, notes, and snippets.

@marsinearth
Created July 24, 2018 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marsinearth/bbc7dfa17c78784669cd08f9337bd8f2 to your computer and use it in GitHub Desktop.
Save marsinearth/bbc7dfa17c78784669cd08f9337bd8f2 to your computer and use it in GitHub Desktop.
debounce예제
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>
)
}
}
@choipd
Copy link

choipd commented Aug 13, 2018

Simple and helpful snippet! Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment