Skip to content

Instantly share code, notes, and snippets.

@kiok46
Created June 10, 2018 12:31
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 kiok46/ac019e751abb857a73f8a5f247d1d8b3 to your computer and use it in GitHub Desktop.
Save kiok46/ac019e751abb857a73f8a5f247d1d8b3 to your computer and use it in GitHub Desktop.
Preventing React-Navigation Multiple Screen Instances
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