diff options
author | Victor Chabbert <chabbertvi@eisti.eu> | 2017-07-25 00:09:31 +0200 |
---|---|---|
committer | Victor Chabbert <chabbertvi@eisti.eu> | 2017-08-07 22:41:20 +0200 |
commit | 3b1e1a77dbf93f5312f90b6545a1f34b5b609792 (patch) | |
tree | ff479637adcf67ac75894f81189bb2604f6e17ab /frontend/src | |
parent | Remove redux-saga-router (diff) | |
download | seven-wonders-3b1e1a77dbf93f5312f90b6545a1f34b5b609792.tar.gz seven-wonders-3b1e1a77dbf93f5312f90b6545a1f34b5b609792.tar.bz2 seven-wonders-3b1e1a77dbf93f5312f90b6545a1f34b5b609792.zip |
Updrade react router and react router redux
Diffstat (limited to 'frontend/src')
-rw-r--r-- | frontend/src/index.js | 12 | ||||
-rw-r--r-- | frontend/src/store.js | 17 |
2 files changed, 16 insertions, 13 deletions
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( <Provider store={store}> - <Router history={history} routes={routes} /> + <ConnectedRouter history={history}> + <Switch> + <Route path="/" component={HomePage} /> + </Switch> + </ConnectedRouter> </Provider>, 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, }; } |