Skip to content

Commit 9bc254c

Browse files
authoredMay 28, 2017
Merge pull request #2 from notrab/fix-change-route-dispatch
Fix changePage function
2 parents 985eec5 + 05db700 commit 9bc254c

File tree

5 files changed

+119
-141
lines changed

5 files changed

+119
-141
lines changed
 

‎package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"react-scripts": "1.0.0"
77
},
88
"dependencies": {
9-
"react": "^15.4.2",
10-
"react-dom": "^15.4.2",
11-
"react-redux": "^5.0.3",
12-
"react-router": "^4.0.0",
13-
"react-router-dom": "^4.0.0",
9+
"react": "^15.5.4",
10+
"react-dom": "^15.5.4",
11+
"react-redux": "^5.0.5",
12+
"react-router": "^4.1.1",
13+
"react-router-dom": "^4.1.1",
1414
"react-router-redux": "next",
1515
"redux": "^3.6.0",
1616
"redux-thunk": "^2.2.0",

‎src/containers/app/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
2-
import { Link } from 'react-router-dom'
2+
import { Route, Link } from 'react-router-dom'
3+
import Home from '../home'
4+
import About from '../about'
35

46
const App = ({ children }) => (
57
<div>
@@ -9,7 +11,8 @@ const App = ({ children }) => (
911
</header>
1012

1113
<main>
12-
{children}
14+
<Route exact path="/" component={Home} />
15+
<Route exact path="/about-us" component={About} />
1316
</main>
1417
</div>
1518
)

‎src/containers/home/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ const mapDispatchToProps = dispatch => bindActionCreators({
3939
incrementAsync,
4040
decrement,
4141
decrementAsync,
42-
changePage: () => {
43-
dispatch(push('/about-us'))
44-
}
42+
changePage: () => push('/about-us')
4543
}, dispatch)
4644

4745
export default connect(

‎src/index.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import React from 'react'
22
import { render } from 'react-dom'
33
import { Provider } from 'react-redux'
4-
import { Route } from 'react-router'
54
import { ConnectedRouter } from 'react-router-redux'
65
import store, { history } from './store'
76
import App from './containers/app'
8-
import Home from './containers/home'
9-
import About from './containers/about'
107

118
import 'sanitize.css/sanitize.css'
129
import './index.css'
@@ -16,10 +13,9 @@ const target = document.querySelector('#root')
1613
render(
1714
<Provider store={store}>
1815
<ConnectedRouter history={history}>
19-
<App>
20-
<Route exact path="/" component={Home} />
21-
<Route exact path="/about-us" component={About} />
22-
</App>
16+
<div>
17+
<App />
18+
</div>
2319
</ConnectedRouter>
2420
</Provider>,
2521
target

0 commit comments

Comments
 (0)
Please sign in to comment.