@@ -9,7 +9,7 @@ import Style from './ExampleScreenStyle'
9
9
/**
10
10
* This is an example of a container component.
11
11
*
12
- * This screen displays a little help message and shows the weather temperature .
12
+ * This screen displays a little help message and informations about a fake user .
13
13
* Feel free to remove it.
14
14
*/
15
15
@@ -20,43 +20,48 @@ const instructions = Platform.select({
20
20
21
21
class ExampleScreen extends React . Component {
22
22
componentDidMount ( ) {
23
- this . props . fetchTemperature ( )
23
+ this . props . fetchUser ( )
24
24
}
25
25
26
26
render ( ) {
27
- let temperature = this . props . temperatureIsLoading ? '...' : this . props . temperature
28
- if ( temperature === null ) {
29
- temperature = '??'
27
+ let user = this . props . userIsLoading ? '...' : this . props . user
28
+ if ( user === null ) {
29
+ user = '??'
30
30
}
31
31
32
32
return (
33
33
< View style = { Style . container } >
34
34
< Text style = { Style . title } > TheCodingMachine boilerplate</ Text >
35
35
< Text style = { Style . text } > To get started, edit App.js</ Text >
36
36
< Text style = { Style . text } > { instructions } </ Text >
37
- < Text style = { Style . text } > The weather temperature is: { temperature } </ Text >
38
- < Text style = { Style . text } > { this . props . isHot ? "It's pretty hot!" : '' } </ Text >
39
- < Text style = { Style . text } > { this . props . temperatureErrorMessage } </ Text >
40
- < Button onPress = { this . props . fetchTemperature } title = "Refresh" />
37
+ < Text style = { Style . text } >
38
+ { user === '...'
39
+ ? 'Data are loading...'
40
+ : this . props . userErrorMessage
41
+ ? this . props . userErrorMessage
42
+ : '' }
43
+ </ Text >
44
+ < Text style = { Style . text } > { user ? "I'm a fake user, my name is " + user . name : '' } .</ Text >
45
+ < Button onPress = { this . props . fetchUser } title = "Refresh" />
41
46
</ View >
42
47
)
43
48
}
44
49
}
45
50
46
51
ExampleScreen . propsTypes = {
47
- temperature : PropTypes . number ,
48
- temperatureErrorMessage : PropTypes . string ,
52
+ user : PropTypes . number ,
53
+ userIsLoading : PropTypes . bool ,
54
+ userErrorMessage : PropTypes . string ,
49
55
}
50
56
51
57
const mapStateToProps = ( state ) => ( {
52
- temperature : state . example . get ( 'temperature' ) ,
53
- temperatureErrorMessage : state . example . get ( 'temperatureErrorMessage' ) ,
54
- temperatureIsLoading : state . example . get ( 'temperatureIsLoading' ) ,
55
- isHot : isHot ( state ) ,
58
+ user : state . example . get ( 'user' ) . toJS ( ) ,
59
+ userIsLoading : state . example . get ( 'userIsLoading' ) ,
60
+ userErrorMessage : state . example . get ( 'userErrorMessage' ) ,
56
61
} )
57
62
58
63
const mapDispatchToProps = ( dispatch ) => ( {
59
- fetchTemperature : ( ) => dispatch ( ExampleActions . fetchTemperature ( ) ) ,
64
+ fetchUser : ( ) => dispatch ( ExampleActions . fetchUser ( ) ) ,
60
65
} )
61
66
62
67
export default connect (
0 commit comments