Created
June 10, 2018 12:31
-
-
Save kiok46/ac019e751abb857a73f8a5f247d1d8b3 to your computer and use it in GitHub Desktop.
Preventing React-Navigation Multiple Screen Instances
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, { Component } from 'react'; | |
import { TouchableOpacity } from 'react-native'; | |
import PropTypes from 'prop-types'; | |
import multipleTapHandler from 'multipleTapHandler'; | |
class Button extends Component { | |
render() { | |
return ( | |
<TouchableOpacity | |
{...this.props} | |
onPress={multipleTapHandler(() => this.props.onPress(), this.props.ignoreMultipleTouches ? 500 : 0)} | |
/> | |
); | |
} | |
} | |
Button.defaultProps = { | |
ignoreMultipleTouches: false | |
}; | |
Button.propTypes = { | |
ignoreMultipleTouches: PropTypes.bool | |
}; | |
export default Button; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment