Skip to content
This repository was archived by the owner on Sep 11, 2018. It is now read-only.

Commit 0df2690

Browse files
author
David Zukowski
committed
upgrade(react-router-redux): ^3.0.0 -> ^4.0.0-beta
1 parent 3b57c1c commit 0df2690

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"better-npm-run": "0.0.5",
6161
"co-request": "^1.0.0",
6262
"debug": "^2.2.0",
63-
"history": "^2.0.0-rc2",
63+
"history": "^2.0.0",
6464
"iconv-lite": "^0.4.13",
6565
"koa": "^2.0.0-alpha.3",
6666
"koa-connect-history-api-fallback": "^0.3.0",
@@ -70,7 +70,7 @@
7070
"react-dom": "^0.14.0",
7171
"react-redux": "^4.0.0",
7272
"react-router": "^2.0.0",
73-
"react-router-redux": "^3.0.0",
73+
"react-router-redux": "^4.0.0-beta",
7474
"redux": "^3.0.0",
7575
"redux-thunk": "^1.0.0",
7676
"url": "^0.11.0",

src/main.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
import React from 'react'
22
import ReactDOM from 'react-dom'
33
import { browserHistory } from 'react-router'
4+
import { syncHistoryWithStore } from 'react-router-redux'
45
import makeRoutes from './routes'
56
import Root from './containers/Root'
67
import configureStore from './redux/configureStore'
78

9+
// Create redux store and sync with react-router-redux. We have installed the
10+
// react-router-redux reducer under the key "router" in src/routes/index.js,
11+
// so we need to provide a custom `selectLocationState` to inform
12+
// react-router-redux of its location.
813
const initialState = window.__INITIAL_STATE__
9-
const store = configureStore({ initialState, history })
14+
const store = configureStore(initialState)
15+
const history = syncHistoryWithStore(browserHistory, store, {
16+
selectLocationState: (state) => state.router
17+
})
1018

19+
// Now that we have the Redux store, we can create our routes. We provide
20+
// the store to the route definitions so that routes have access to it for
21+
// hooks such as `onEnter`.
1122
const routes = makeRoutes(store)
1223

13-
// Render the React application to the DOM
24+
// Now that redux and react-router have been configured, we can render the
25+
// React application to the DOM!
1426
ReactDOM.render(
15-
<Root history={browserHistory} routes={routes} store={store} />,
27+
<Root history={history} routes={routes} store={store} />,
1628
document.getElementById('root')
1729
)

src/redux/configureStore.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import { applyMiddleware, compose, createStore } from 'redux'
2-
import { syncHistory } from 'react-router-redux'
32
import thunk from 'redux-thunk'
43
import rootReducer from './rootReducer'
54

6-
export default function configureStore ({ initialState = {}, history }) {
7-
// Sync with router via history instance (main.js)
8-
const routerMiddleware = syncHistory(history)
9-
5+
export default function configureStore (initialState = {}) {
106
// Compose final middleware and use devtools in debug environment
11-
let middleware = applyMiddleware(thunk, routerMiddleware)
7+
let middleware = applyMiddleware(thunk)
128
if (__DEBUG__) {
139
const devTools = window.devToolsExtension
1410
? window.devToolsExtension()
@@ -18,7 +14,6 @@ export default function configureStore ({ initialState = {}, history }) {
1814

1915
// Create final store and subscribe router in debug env ie. for devtools
2016
const store = middleware(createStore)(rootReducer, initialState)
21-
if (__DEBUG__) routerMiddleware.listenForReplays(store, ({ router }) => router.location)
2217

2318
if (module.hot) {
2419
module.hot.accept('./rootReducer', () => {

src/redux/rootReducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { combineReducers } from 'redux'
2-
import { routeReducer as router } from 'react-router-redux'
2+
import { routerReducer as router } from 'react-router-redux'
33
import counter from './modules/counter'
44

55
export default combineReducers({

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy