UNPKG

934 BJavaScriptView Raw
1import React, {
2 PropTypes,
3 ViewPropTypes,
4 Component,
5} from 'react';
6
7import {
8 TouchableOpacity,
9 TouchableNativeFeedback,
10 View,
11 Platform,
12 StyleSheet,
13} from 'react-native';
14
15class Button extends Component {
16 static propTypes = {
17 children: PropTypes.element,
18 }
19 static defaultProps = {
20 children: null,
21 }
22 renderBtn = () => {
23 let btn;
24 const props = this.props;
25 const children = this.props.children;
26 if (Platform.OS === 'ios') {
27 btn = (
28 <TouchableOpacity {...props}>
29 {children}
30 </TouchableOpacity>);
31 } else {
32 btn = (
33 <TouchableNativeFeedback
34 delayPressIn={0}
35 background={TouchableNativeFeedback.SelectableBackground()}
36 {...props}
37 >
38 {children}
39 </TouchableNativeFeedback>);
40 }
41 return btn;
42 }
43 render() {
44 return (
45 this.renderBtn()
46 );
47 }
48}
49
50export default Button;