Skip to content

Commit f9240b0

Browse files
committed
Use react-redux-router@next (compatible with react-router v4)
1 parent e58c473 commit f9240b0

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

client/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import 'babel-polyfill';
22
import React from 'react';
33
import ReactDOM from 'react-dom';
44
import { Provider } from 'react-redux';
5-
import { BrowserRouter } from 'react-router-dom';
6-
// import { browserHistory } from 'react-router';
7-
// import { syncHistoryWithStore } from 'react-router-redux';
5+
import { ConnectedRouter } from 'react-router-redux';
86
import { AppContainer } from 'react-hot-loader';
7+
import createHistory from 'history/createBrowserHistory';
98
import configureStore from 'store';
109
import App from 'containers/App';
1110

11+
const history = createHistory();
12+
1213
/* Images
1314
* This space is reserved for images that are required by server rendering,
1415
* e.g. the favicon and any other images that need to be in the base HTML file.
@@ -21,16 +22,15 @@ const rootElement = document.getElementById('app');
2122
// Creates the Redux store based on the initial state passed down by the server
2223
// rendering.
2324
const initialState = window.__INITIAL_STATE__;
24-
const store = configureStore(initialState);
25-
// const history = syncHistoryWithStore(browserHistory, store);
25+
const store = configureStore(initialState, history);
2626

2727
const render = (Component) => {
2828
ReactDOM.render(
2929
<Provider store={store}>
3030
<AppContainer>
31-
<BrowserRouter>
31+
<ConnectedRouter history={history}>
3232
<Component />
33-
</BrowserRouter>
33+
</ConnectedRouter>
3434
</AppContainer>
3535
</Provider>,
3636
rootElement

common/js/store/index.dev.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@ import { compose, createStore, applyMiddleware } from 'redux';
22
import rootReducer from 'reducers';
33
import DevTools from 'containers/DevTools';
44
import { createLogger } from 'redux-logger';
5+
import { routerMiddleware } from 'react-router-redux';
56

6-
export default function configureStore(initialState) {
7+
export default function configureStore(initialState, history = null) {
78
/* Middleware
89
* Configure this array with the middleware that you want included
910
*/
1011
let middleware = [
1112
createLogger()
1213
];
1314

15+
if (history) {
16+
middleware.push(routerMiddleware(history));
17+
}
18+
1419
// Add universal enhancers here
1520
let enhancers = [
1621
DevTools.instrument()

common/js/store/index.prod.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import { compose, createStore, applyMiddleware } from 'redux';
22
import rootReducer from 'reducers';
3+
import { routerMiddleware } from 'react-router-redux';
34

4-
export default function configureStore(initialState) {
5+
export default function configureStore(initialState, history = null) {
56
/* Middleware
67
* Configure this array with the middleware that you want included.
78
*/
89
let middleware = [];
910

11+
if (history) {
12+
middleware.push(routerMiddleware(history));
13+
}
14+
1015
// Add universal enhancers here
1116
let enhancers = [];
1217

0 commit comments

Comments
 (0)