Implemented react-router v4 to ReactRedux template

This commit is contained in:
Keven van Zuijlen
2017-04-12 21:28:23 +02:00
committed by Steve Sanderson
parent c791ceee49
commit 785e7d48a2
9 changed files with 67 additions and 69 deletions

View File

@@ -1,15 +1,17 @@
import { createStore, applyMiddleware, compose, combineReducers, GenericStoreEnhancer } from 'redux';
import thunk from 'redux-thunk';
import { routerReducer } from 'react-router-redux';
import { routerReducer, routerMiddleware } from 'react-router-redux';
import * as Store from './store';
import { History } from 'history';
export default function configureStore(initialState?: Store.ApplicationState) {
export default function configureStore(history: History, initialState?: Store.ApplicationState) {
// Build middleware. These are functions that can process the actions before they reach the store.
const windowIfDefined = typeof window === 'undefined' ? null : window as any;
// If devTools is installed, connect to it
const devToolsExtension = windowIfDefined && windowIfDefined.devToolsExtension as () => GenericStoreEnhancer;
const middlewares = [thunk, routerMiddleware(history)];
const createStoreWithMiddleware = compose(
applyMiddleware(thunk),
applyMiddleware(...middlewares),
devToolsExtension ? devToolsExtension() : f => f
)(createStore);