Skip to content

Commit f0132a0

Browse files
committed
Merge pull request #453 from hartzis/update-counter-example
Update counter example to recent react-redux
2 parents 27fa07c + 9db0c57 commit f0132a0

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
@@ -30,7 +30,7 @@
3030
"homepage": "https://github.com/gaearon/redux#readme",
3131
"dependencies": {
3232
"react": "^0.13.3",
33-
"react-redux": "^0.4.0",
33+
"react-redux": "^0.8.0",
3434
"redux": "^1.0.0-rc",
3535
"redux-thunk": "^0.1.0"
3636
},

0 commit comments

Comments
 (0)