Skip to content

Commit 3e8453d

Browse files
committed
Merge pull request #951 from svsool/master
update react-router-redux to 4.0.0
2 parents fd7b35d + 19f1494 commit 3e8453d

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"react-redux": "^4.0.0",
126126
"react-router": "2.0.0",
127127
"react-router-bootstrap": "^0.20.1",
128-
"react-router-redux": "^3.0.0",
128+
"react-router-redux": "^4.0.0",
129129
"redux": "^3.0.4",
130130
"redux-async-connect": "^1.0.0-rc2",
131131
"redux-form": "^3.0.12",

src/client.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ import ApiClient from './helpers/ApiClient';
99
import io from 'socket.io-client';
1010
import {Provider} from 'react-redux';
1111
import { Router, browserHistory } from 'react-router';
12+
import { syncHistoryWithStore } from 'react-router-redux';
1213
import { ReduxAsyncConnect } from 'redux-async-connect';
1314
import useScroll from 'scroll-behavior/lib/useStandardScroll';
1415

1516
import getRoutes from './routes';
1617

1718
const client = new ApiClient();
18-
const history = useScroll(() => browserHistory)();
19+
const _browserHistory = useScroll(() => browserHistory)();
1920
const dest = document.getElementById('content');
20-
const store = createStore(history, client, window.__data);
21+
const store = createStore(_browserHistory, client, window.__data);
22+
const history = syncHistoryWithStore(_browserHistory, store);
2123

2224
function initSocket() {
2325
const socket = io('', {path: '/ws'});

src/containers/App/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Helmet from 'react-helmet';
99
import { isLoaded as isInfoLoaded, load as loadInfo } from 'redux/modules/info';
1010
import { isLoaded as isAuthLoaded, load as loadAuth, logout } from 'redux/modules/auth';
1111
import { InfoBar } from 'components';
12-
import { routeActions } from 'react-router-redux';
12+
import { push } from 'react-router-redux';
1313
import config from '../../config';
1414
import { asyncConnect } from 'redux-async-connect';
1515

@@ -29,7 +29,7 @@ import { asyncConnect } from 'redux-async-connect';
2929
}])
3030
@connect(
3131
state => ({user: state.auth.user}),
32-
{logout, pushState: routeActions.push})
32+
{logout, pushState: push})
3333
export default class App extends Component {
3434
static propTypes = {
3535
children: PropTypes.object.isRequired,

src/redux/create.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { createStore as _createStore, applyMiddleware, compose } from 'redux';
22
import createMiddleware from './middleware/clientMiddleware';
3-
import { syncHistory } from 'react-router-redux';
3+
import { routerMiddleware } from 'react-router-redux';
44

55
export default function createStore(history, client, data) {
66
// Sync dispatched route actions to the history
7-
const reduxRouterMiddleware = syncHistory(history);
7+
const reduxRouterMiddleware = routerMiddleware(history);
88

99
const middleware = [createMiddleware(client), reduxRouterMiddleware];
1010

@@ -24,7 +24,6 @@ export default function createStore(history, client, data) {
2424
const reducer = require('./modules/reducer');
2525
const store = finalCreateStore(reducer, data);
2626

27-
reduxRouterMiddleware.listenForReplays(store);
2827

2928
if (__DEVELOPMENT__ && module.hot) {
3029
module.hot.accept('./modules/reducer', () => {

src/redux/modules/reducer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { combineReducers } from 'redux';
22
import multireducer from 'multireducer';
3-
import { routeReducer } from 'react-router-redux';
3+
import { routerReducer } from 'react-router-redux';
44
import {reducer as reduxAsyncConnect} from 'redux-async-connect';
55

66
import auth from './auth';
@@ -10,7 +10,7 @@ import info from './info';
1010
import widgets from './widgets';
1111

1212
export default combineReducers({
13-
routing: routeReducer,
13+
routing: routerReducer,
1414
reduxAsyncConnect,
1515
auth,
1616
form,

src/server.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import PrettyError from 'pretty-error';
1313
import http from 'http';
1414

1515
import { match } from 'react-router';
16+
import { syncHistoryWithStore } from 'react-router-redux';
1617
import { ReduxAsyncConnect, loadOnServer } from 'redux-async-connect';
1718
import createHistory from 'react-router/lib/createMemoryHistory';
1819
import {Provider} from 'react-redux';
@@ -66,9 +67,9 @@ app.use((req, res) => {
6667
webpackIsomorphicTools.refresh();
6768
}
6869
const client = new ApiClient(req);
69-
const history = createHistory(req.originalUrl);
70-
71-
const store = createStore(history, client);
70+
const memoryHistory = createHistory(req.originalUrl);
71+
const store = createStore(memoryHistory, client);
72+
const history = syncHistoryWithStore(memoryHistory, store);
7273

7374
function hydrateOnClient() {
7475
res.send('<!doctype html>\n' +

0 commit comments

Comments
 (0)