Skip to content

Commit

Permalink
Upgrade to connected-react-router
Browse files Browse the repository at this point in the history
  • Loading branch information
notrab committed Jul 9, 2018
1 parent 1dcaf70 commit e3ce666
Show file tree
Hide file tree
Showing 6 changed files with 1,665 additions and 1,464 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"react-scripts": "1.1.4"
},
"dependencies": {
"connected-react-router": "^4.3.0",
"react": "16.4.1",
"react-dom": "16.4.1",
"react-redux": "5.0.7",
"react-router": "4.3.1",
"react-router-dom": "4.3.1",
"react-router-redux": "5.0.0-alpha.9",
"redux": "4.0.0",
"redux-thunk": "2.3.0",
"sanitize.css": "6.0.0",
Expand Down
23 changes: 11 additions & 12 deletions src/containers/home/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { push } from 'react-router-redux'
import { push } from 'connected-react-router'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import {
Expand All @@ -15,18 +15,14 @@ const Home = props => (
<p>Count: {props.count}</p>

<p>
<button onClick={props.increment} disabled={props.isIncrementing}>
Increment
</button>
<button onClick={props.increment}>Increment</button>
<button onClick={props.incrementAsync} disabled={props.isIncrementing}>
Increment Async
</button>
</p>

<p>
<button onClick={props.decrement} disabled={props.isDecrementing}>
Decrement
</button>
<button onClick={props.decrement}>Decrement</button>
<button onClick={props.decrementAsync} disabled={props.isDecrementing}>
Decrement Async
</button>
Expand All @@ -40,10 +36,10 @@ const Home = props => (
</div>
)

const mapStateToProps = state => ({
count: state.counter.count,
isIncrementing: state.counter.isIncrementing,
isDecrementing: state.counter.isDecrementing
const mapStateToProps = ({ counter }) => ({
count: counter.count,
isIncrementing: counter.isIncrementing,
isDecrementing: counter.isDecrementing
})

const mapDispatchToProps = dispatch =>
Expand All @@ -58,4 +54,7 @@ const mapDispatchToProps = dispatch =>
dispatch
)

export default connect(mapStateToProps, mapDispatchToProps)(Home)
export default connect(
mapStateToProps,
mapDispatchToProps
)(Home)
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import { ConnectedRouter } from 'react-router-redux'
import { ConnectedRouter } from 'connected-react-router'
import store, { history } from './store'
import App from './containers/app'

Expand Down
2 changes: 0 additions & 2 deletions src/modules/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { combineReducers } from 'redux'
import { routerReducer } from 'react-router-redux'
import counter from './counter'

export default combineReducers({
router: routerReducer,
counter
})
13 changes: 10 additions & 3 deletions src/store.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createStore, applyMiddleware, compose } from 'redux'
import { routerMiddleware } from 'react-router-redux'
import { connectRouter, routerMiddleware } from 'connected-react-router'
import thunk from 'redux-thunk'
import createHistory from 'history/createBrowserHistory'
import rootReducer from './modules'
Expand All @@ -18,6 +18,13 @@ if (process.env.NODE_ENV === 'development') {
}
}

const composedEnhancers = compose(applyMiddleware(...middleware), ...enhancers)
const composedEnhancers = compose(
applyMiddleware(...middleware),
...enhancers
)

export default createStore(rootReducer, initialState, composedEnhancers)
export default createStore(
connectRouter(history)(rootReducer),
initialState,
composedEnhancers
)
Loading

0 comments on commit e3ce666

Please sign in to comment.