forked from osdio/noder-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorHandle.js
More file actions
61 lines (56 loc) · 1.33 KB
/
ErrorHandle.js
File metadata and controls
61 lines (56 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React, {Component} from 'react'
import {View, StyleSheet, TouchableOpacity, Text} from 'react-native'
import PropTypes from 'prop-types'
class ErrorHandle extends Component {
static propTypes = {
infoText: PropTypes.string,
onPress: PropTypes.func,
buttonText: PropTypes.string
};
static defaultProps = {
infoText: '网络出错啦, 请点击按钮重新加载',
buttonText: '重新获取'
};
render () {
return (
<View style={styles.container}>
<Text style={styles.infoText}>
{ this.props.infoText }
</Text>
<TouchableOpacity onPress={this.props.onPress}>
<View style={styles.button}>
<Text style={styles.buttonText}>
{ this.props.buttonText }
</Text>
</View>
</TouchableOpacity>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
height: 130,
flexDirection: 'column',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: 'white',
padding: 20
},
button: {
width: 150,
height: 40,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
borderRadius: 5,
backgroundColor: '#E74C3C'
},
infoText: {
fontSize: 20
},
buttonText: {
color: 'white'
}
})
export default ErrorHandle