@@ -24,27 +24,28 @@ class ExampleScreen extends React.Component {
24
24
}
25
25
26
26
render ( ) {
27
- let user = this . props . userIsLoading ? '...' : this . props . user
28
- if ( user === null ) {
29
- user = '??'
27
+ let isLoading = this . props . userIsLoading ? 'Data are loading...' : ''
28
+ let user = this . props . user
29
+ let error = this . props . userErrorMessage
30
+ let result = null
31
+ if ( user && ! error ) {
32
+ result =
33
+ "I'm a fake user, my name is " + user . name + '.\n' + this . props . liveInEurope
34
+ ? 'I live in Europe !'
35
+ : "I don't live in Europe."
30
36
}
31
37
32
38
return (
33
39
< View style = { Style . container } >
34
40
< Text style = { Style . title } > TheCodingMachine boilerplate</ Text >
35
41
< Text style = { Style . text } > To get started, edit App.js</ Text >
36
- < Text style = { Style . text } > { instructions } </ Text >
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
- < Text style = { Style . text } >
46
- { this . props . liveInEurope ? 'I live in Europe !' : "I don't live in Europe." }
47
- </ Text >
42
+ < Text style = { Style . instructions } > { instructions } </ Text >
43
+ < Text style = { Style . loading } > { isLoading } </ Text >
44
+ { user && ! error ? (
45
+ < Text style = { Style . result } > { result } </ Text >
46
+ ) : (
47
+ < Text style = { Style . error } > { error } </ Text >
48
+ ) }
48
49
< Button onPress = { this . props . fetchUser } title = "Refresh" />
49
50
</ View >
50
51
)
0 commit comments