UNPKG

react-native-snackbar-component

Version:
53 lines (47 loc) 958 B
import React from 'react'; import PropTypes from 'prop-types'; import { View, TouchableOpacity, TouchableNativeFeedback, ViewPropTypes, } from 'react-native'; import { IS_ANDROID, IS_LT_LOLLIPOP, noop, } from './utils'; const Touchable = ({ onPress, style, children }) => { if (IS_ANDROID && !IS_LT_LOLLIPOP) { return ( <TouchableNativeFeedback background={TouchableNativeFeedback.SelectableBackgroundBorderless()} onPress={onPress} > <View style={style} > {children} </View> </TouchableNativeFeedback> ); } return ( <TouchableOpacity onPress={onPress} style={style} > {children} </TouchableOpacity> ); }; Touchable.propTypes = { onPress: PropTypes.func, style: ViewPropTypes.style, children: PropTypes.node.isRequired, }; Touchable.defaultProps = { onPress: noop, style: {}, }; export default Touchable;