@@ -29,47 +29,33 @@ import {
29
29
TouchableNativeFeedback ,
30
30
View
31
31
} from 'react-native'
32
- import PropTypes from 'prop-types' ;
32
+ const { OS } = Platform ;
33
33
34
- const OS = Platform . OS ;
34
+ import PropTypes from 'prop-types' ;
35
35
36
36
class TouchableEffect extends Component {
37
37
38
38
render ( ) {
39
- const { onPress, children, style, background, delayPressIn } = this . props ;
40
-
41
39
let touchable ;
42
40
43
41
if ( OS === 'android' ) {
44
- touchable = < TouchableNativeFeedback
45
- style = { style }
46
- onPress = { onPress }
47
- delayPressIn = { delayPressIn }
48
- background = { background } >
49
- { children }
50
- </ TouchableNativeFeedback >
42
+ touchable = < TouchableNativeFeedback { ...this . props } />
51
43
} else {
52
- touchable = < TouchableOpacity
53
- style = { style }
54
- delayPressIn = { delayPressIn }
55
- onPress = { onPress } >
56
- { children }
57
- </ TouchableOpacity >
44
+ touchable = < TouchableOpacity { ...this . props } />
58
45
}
59
46
60
47
return touchable ;
61
48
}
62
49
}
63
50
64
- TouchableEffect . propTypes = {
65
- onPress : TouchableOpacity . propTypes . onPress . isRequired ,
66
- style : View . propTypes . style ,
67
- delayPressIn : TouchableOpacity . propTypes . delayPressIn ,
68
- background : OS === 'android' ? TouchableNativeFeedback . propTypes . background : PropTypes . any ,
51
+ if ( OS === 'android' ) {
52
+ TouchableEffect . propTypes = { ...TouchableNativeFeedback . propTypes } ;
53
+ } else {
54
+ TouchableEffect . propTypes = { ...TouchableOpacity . propTypes } ;
69
55
}
70
56
71
57
TouchableEffect . defaultProps = {
72
- background : OS === 'android' ? TouchableNativeFeedback . SelectableBackground ( ) : null
58
+ background : OS === 'android' ? TouchableNativeFeedback . SelectableBackground ( ) : undefined
73
59
} ;
74
60
75
61
export default TouchableEffect
0 commit comments