Skip to content

Instantly share code, notes, and snippets.

@AllGistsEqual
Last active April 28, 2020 16:21
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 AllGistsEqual/5d5afa941c019fbf17df98207e0a42bd to your computer and use it in GitHub Desktop.
Save AllGistsEqual/5d5afa941c019fbf17df98207e0a42bd to your computer and use it in GitHub Desktop.
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