Last active
April 28, 2020 16:21
-
-
Save AllGistsEqual/5d5afa941c019fbf17df98207e0a42bd to your computer and use it in GitHub Desktop.
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 from 'react' | |
import { TouchableWithoutFeedback, StyleSheet, View } from 'react-native' | |
import PropTypes from 'prop-types' | |
const TouchableWrapper = ({ handlePress, children }) => ( | |
<TouchableWithoutFeedback | |
style={styles.touchableWrapper} | |
onPress={() => handlePress()} | |
> | |
<View style={styles.touchableWrapperHelper}> | |
{children} | |
</View> | |
</TouchableWithoutFeedback> | |
) | |
const styles = StyleSheet.create({ | |
touchableWrapper: { | |
width: '100%', | |
height: '100%', | |
}, | |
touchableWrapperHelper: { | |
position: 'absolute', | |
backgroundColor: 'red', | |
top: 0, | |
bottom: 0, | |
left: 0, | |
right: 0, | |
}, | |
}) | |
TouchableWrapper.propTypes = { | |
handlePress: PropTypes.func.isRequired, | |
children: PropTypes.node.isRequired, | |
} | |
export default TouchableWrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment