File tree Expand file tree Collapse file tree 2 files changed +7
-14
lines changed Expand file tree Collapse file tree 2 files changed +7
-14
lines changed Original file line number Diff line number Diff line change 1- import React , { Component } from 'react' ;
21import { bindActionCreators } from 'redux' ;
32import { connect } from 'react-redux' ;
43import Counter from '../components/Counter' ;
54import * as CounterActions from '../actions/CounterActions' ;
65
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
149 }
1510}
1611
17- function select ( state ) {
18- return {
19- counter : state . counter
20- } ;
12+ function mapDispatchToProps ( dispatch ) {
13+ return bindActionCreators ( CounterActions , dispatch ) ;
2114}
2215
23- export default connect ( select ) ( CounterApp ) ;
16+ export default connect ( mapStateToProps , mapDispatchToProps ) ( Counter ) ;
Original file line number Diff line number Diff line change 2929 "homepage" : " https://github.com/gaearon/redux#readme" ,
3030 "dependencies" : {
3131 "react" : " ^0.13.3" ,
32- "react-redux" : " ^0.4 .0" ,
32+ "react-redux" : " ^0.8 .0" ,
3333 "redux" : " ^1.0.0-rc" ,
3434 "redux-thunk" : " ^0.1.0"
3535 },
You can’t perform that action at this time.
0 commit comments