File tree 2 files changed +7
-14
lines changed 2 files changed +7
-14
lines changed Original file line number Diff line number Diff line change 1
- import React , { Component } from 'react' ;
2
1
import { bindActionCreators } from 'redux' ;
3
2
import { connect } from 'react-redux' ;
4
3
import Counter from '../components/Counter' ;
5
4
import * as CounterActions from '../actions/CounterActions' ;
6
5
7
- class CounterApp extends Component {
8
- render ( ) {
9
- const { counter, dispatch } = this . props ;
10
- return (
11
- < Counter counter = { counter }
12
- { ...bindActionCreators ( CounterActions , dispatch ) } />
13
- ) ;
6
+ function mapStateToProps ( state ) {
7
+ return {
8
+ counter : state . counter
14
9
}
15
10
}
16
11
17
- function select ( state ) {
18
- return {
19
- counter : state . counter
20
- } ;
12
+ function mapDispatchToProps ( dispatch ) {
13
+ return bindActionCreators ( CounterActions , dispatch ) ;
21
14
}
22
15
23
- export default connect ( select ) ( CounterApp ) ;
16
+ export default connect ( mapStateToProps , mapDispatchToProps ) ( Counter ) ;
Original file line number Diff line number Diff line change 30
30
"homepage" : " https://github.com/gaearon/redux#readme" ,
31
31
"dependencies" : {
32
32
"react" : " ^0.13.3" ,
33
- "react-redux" : " ^0.4 .0" ,
33
+ "react-redux" : " ^0.8 .0" ,
34
34
"redux" : " ^1.0.0-rc" ,
35
35
"redux-thunk" : " ^0.1.0"
36
36
},
You can’t perform that action at this time.
0 commit comments