1- import React , { Component } from 'react'
1+ import React from 'react'
22import { push } from 'react-router-redux'
33import { bindActionCreators } from 'redux'
44import { connect } from 'react-redux'
5- import { incrementAsync , decrementAsync } from '../../modules/counter'
5+ import {
6+ increment ,
7+ incrementAsync ,
8+ decrement ,
9+ decrementAsync
10+ } from '../../modules/counter'
611
7- class Home extends Component {
8- render ( ) {
9- const { count, incrementAsync, decrementAsync, isIncrementing, isDecrementing, changePage } = this . props
12+ const Home = props => (
13+ < div >
14+ < h1 > Home</ h1 >
15+ < p > Count: { props . count } </ p >
1016
11- return (
12- < div >
13- < h1 > Home</ h1 >
14- < p > Welcome home!</ p >
15- < p > Count: { count } </ p >
16- < p > < button onClick = { incrementAsync } disabled = { isIncrementing } > Increment Async</ button > < button onClick = { decrementAsync } disabled = { isDecrementing } > Decrement Async</ button > </ p >
17- < button onClick = { ( ) => changePage ( ) } > Go to about page via redux</ button >
18- </ div >
19- )
20- }
21- }
17+ < p >
18+ < button onClick = { props . increment } disabled = { props . isIncrementing } > Increment</ button >
19+ < button onClick = { props . incrementAsync } disabled = { props . isIncrementing } > Increment Async</ button >
20+ </ p >
21+
22+ < p >
23+ < button onClick = { props . decrement } disabled = { props . isDecrementing } > Decrementing</ button >
24+ < button onClick = { props . decrementAsync } disabled = { props . isDecrementing } > Decrement Async</ button >
25+ </ p >
26+
27+ < p > < button onClick = { ( ) => props . changePage ( ) } > Go to about page via redux</ button > </ p >
28+ </ div >
29+ )
2230
2331const mapStateToProps = state => ( {
2432 count : state . counter . count ,
@@ -27,11 +35,16 @@ const mapStateToProps = state => ({
2735} )
2836
2937const mapDispatchToProps = dispatch => bindActionCreators ( {
38+ increment,
3039 incrementAsync,
40+ decrement,
3141 decrementAsync,
3242 changePage : ( ) => {
3343 dispatch ( push ( '/about-us' ) )
3444 }
3545} , dispatch )
3646
37- export default connect ( mapStateToProps , mapDispatchToProps ) ( Home )
47+ export default connect (
48+ mapStateToProps ,
49+ mapDispatchToProps
50+ ) ( Home )
0 commit comments