From 39347ea42fe9d8de5afe1e440c85d421428c53cd Mon Sep 17 00:00:00 2001 From: "C.T. Lin" Date: Thu, 3 Mar 2016 15:23:26 +0800 Subject: [PATCH] Upgraded react-router-redux to v4 --- app/index.js | 6 +++--- app/reducers/index.js | 2 +- app/store/configureStore.development.js | 7 +++---- app/store/configureStore.production.js | 5 +++-- package.json | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/index.js b/app/index.js index 9763070..cadda0e 100644 --- a/app/index.js +++ b/app/index.js @@ -2,17 +2,17 @@ import React from 'react'; import { render } from 'react-dom'; import { Provider } from 'react-redux'; import { Router, hashHistory } from 'react-router'; +import { syncHistoryWithStore } from 'react-router-redux'; import routes from './routes'; import configureStore from './store/configureStore'; import './app.global.css'; const store = configureStore(); +const history = syncHistoryWithStore(hashHistory, store); render( - - {routes} - + , document.getElementById('root') ); diff --git a/app/reducers/index.js b/app/reducers/index.js index 3b679a9..2b013be 100644 --- a/app/reducers/index.js +++ b/app/reducers/index.js @@ -1,5 +1,5 @@ import { combineReducers } from 'redux'; -import { routeReducer as routing } from 'react-router-redux'; +import { routerReducer as routing } from 'react-router-redux'; import counter from './counter'; const rootReducer = combineReducers({ diff --git a/app/store/configureStore.development.js b/app/store/configureStore.development.js index f66b215..57adfe5 100644 --- a/app/store/configureStore.development.js +++ b/app/store/configureStore.development.js @@ -2,11 +2,12 @@ import { createStore, applyMiddleware, compose } from 'redux'; import { persistState } from 'redux-devtools'; import thunk from 'redux-thunk'; import { hashHistory } from 'react-router'; -import { syncHistory } from 'react-router-redux'; +import { routerMiddleware } from 'react-router-redux'; import rootReducer from '../reducers'; import DevTools from '../containers/DevTools'; -const router = syncHistory(hashHistory); +const router = routerMiddleware(hashHistory); + const enhancer = compose( applyMiddleware(thunk, router), DevTools.instrument(), @@ -20,8 +21,6 @@ const enhancer = compose( export default function configureStore(initialState) { const store = createStore(rootReducer, initialState, enhancer); - router.listenForReplays(store); - if (module.hot) { module.hot.accept('../reducers', () => store.replaceReducer(require('../reducers')) diff --git a/app/store/configureStore.production.js b/app/store/configureStore.production.js index 93c42a7..7c13728 100644 --- a/app/store/configureStore.production.js +++ b/app/store/configureStore.production.js @@ -1,10 +1,11 @@ import { createStore, applyMiddleware } from 'redux'; import thunk from 'redux-thunk'; import { hashHistory } from 'react-router'; -import { syncHistory } from 'react-router-redux'; +import { routerMiddleware } from 'react-router-redux'; import rootReducer from '../reducers'; -const router = syncHistory(hashHistory); +const router = routerMiddleware(hashHistory); + const enhancer = applyMiddleware(thunk, router); export default function configureStore(initialState) { diff --git a/package.json b/package.json index 59d3494..3783805 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "react-dom": "^0.14.2", "react-redux": "^4.0.5", "react-router": "^2.0.0", - "react-router-redux": "^3.0.0", + "react-router-redux": "^4.0.0", "redux": "^3.2.1", "redux-promise": "^0.5.0", "redux-thunk": "^1.0.2"