Open ssomnoremac opened 7 years ago
Might be better just as this
if(onPress) {
return (
<TouchableComponent style={[_style, _shorthandStyles, style]} onPress={onPress} {...otherProps} >
{props.children}
</TouchableComponent>
)
} else {
return (
<View style={[_style, _shorthandStyles, style]} {...otherProps} >
{props.children}
</View>
);
}
or actually back to the original
const Component = !otherProps.onPress
? View
: Platform.OS === 'android'
? TouchableNativeFeedback
: TouchableHighlight
and remove onPress
from the Component altogether. I think that would work, be the cleanest.
While TouchableHighlight does accept a style
property, I believe TouchableNativeFeedback / TouchableWithoutFeedback does not.
I'm finding more often than not that I do this:
Why not just toggle the Component type to Touchable (handling Platform differences as well) when onPress is present?
and like so
pass the empty function to
View
? There might be a better way.