From 3b1e1a77dbf93f5312f90b6545a1f34b5b609792 Mon Sep 17 00:00:00 2001 From: Victor Chabbert Date: Tue, 25 Jul 2017 00:09:31 +0200 Subject: Updrade react router and react router redux --- frontend/src/index.js | 12 ++++++++---- frontend/src/store.js | 17 ++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'frontend/src') diff --git a/frontend/src/index.js b/frontend/src/index.js index 17076de5..2dc2442c 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -2,19 +2,23 @@ import 'babel-polyfill'; import React from 'react'; import ReactDOM from 'react-dom'; +import { ConnectedRouter } from 'react-router-redux'; +import { Route, Switch } from 'react-router'; import { Provider } from 'react-redux'; -import { Router } from 'react-router'; import './global-styles.css'; -import { routes } from './routes'; import configureStore from './store'; - +import HomePage from './containers/home'; const initialState = {}; const { store, history } = configureStore(initialState); ReactDOM.render( - + + + + + , document.getElementById('root') ); diff --git a/frontend/src/store.js b/frontend/src/store.js index 47b2073e..37bc0822 100644 --- a/frontend/src/store.js +++ b/frontend/src/store.js @@ -1,17 +1,18 @@ // @flow +import { createStore, applyMiddleware, compose } from 'redux'; +import createHistory from 'history/createBrowserHistory'; +import { routerMiddleware } from 'react-router-redux'; import { fromJS } from 'immutable'; -import { browserHistory } from 'react-router'; -import { routerMiddleware, syncHistoryWithStore } from 'react-router-redux'; -import { applyMiddleware, compose, createStore } from 'redux'; import createSagaMiddleware from 'redux-saga'; import createReducer from './reducers'; -import { makeSelectLocationState } from './redux/app'; import rootSaga from './sagas'; export default function configureStore(initialState: Object = {}) { const sagaMiddleware = createSagaMiddleware(); - const middlewares = [sagaMiddleware, routerMiddleware(browserHistory)]; + const history = createHistory(); + + const middlewares = [sagaMiddleware, routerMiddleware(history)]; const enhancers = [applyMiddleware(...middlewares)]; @@ -23,12 +24,10 @@ export default function configureStore(initialState: Object = {}) { const store = createStore(createReducer(), fromJS(initialState), composeEnhancers(...enhancers)); - sagaMiddleware.run(rootSaga, browserHistory); + sagaMiddleware.run(rootSaga, history); return { store, - history: syncHistoryWithStore(browserHistory, store, { - selectLocationState: makeSelectLocationState(), - }), + history, }; } -- cgit