File tree Expand file tree Collapse file tree 2 files changed +9
-14
lines changed Expand file tree Collapse file tree 2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -15,20 +15,21 @@ export default class Zen extends Component {
15
15
}
16
16
17
17
render ( ) {
18
- const props = this . props
18
+ const { fetchZen, clearZen, zen } = this . props
19
+ const { fetching, text } = zen
19
20
20
21
return (
21
22
< div >
22
23
< div >
23
- < button className = 'btn btn-default' onClick = { props . fetchZen } >
24
- { props . zen . fetching ? 'Fetching...' : 'Fetch' }
24
+ < button className = 'btn btn-default' onClick = { fetchZen } >
25
+ { fetching ? 'Fetching...' : 'Fetch' }
25
26
</ button >
26
27
27
- < button className = 'btn btn-default' onClick = { props . clearZen } > Clear</ button >
28
+ < button className = 'btn btn-default' onClick = { clearZen } > Clear</ button >
28
29
</ div >
29
30
{ this . renderLoading ( ) }
30
31
< div >
31
- { props . zen . text . map ( child ) }
32
+ { text . map ( child ) }
32
33
</ div >
33
34
</ div >
34
35
)
Original file line number Diff line number Diff line change @@ -33,15 +33,9 @@ export function fetchZen () {
33
33
if ( getState ( ) . zen . fetching ) return
34
34
35
35
dispatch ( requestZen ( ) )
36
- return new Promise ( ( resolve ) => {
37
- setTimeout ( ( ) => {
38
- resolve ( )
39
- } , 1000 )
40
- } ) . then ( ( ) => {
41
- fetch ( 'https://api.github.com/zen' )
42
- . then ( data => data . text ( ) )
43
- . then ( text => dispatch ( receiveZen ( text ) ) )
44
- } )
36
+ return fetch ( 'https://api.github.com/zen' )
37
+ . then ( data => data . text ( ) )
38
+ . then ( text => dispatch ( receiveZen ( text ) ) )
45
39
}
46
40
}
47
41
You can’t perform that action at this time.
0 commit comments