Skip to content

Commit 9db0c57

Browse files
author
Brian Hartz
committed
update counter example
1 parent 09b3b1d commit 9db0c57

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed
Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1-
import React, { Component } from 'react';
21
import { bindActionCreators } from 'redux';
32
import { connect } from 'react-redux';
43
import Counter from '../components/Counter';
54
import * 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);

examples/counter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
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
},

0 commit comments

Comments
 (0)