mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Implemented react-router v4 to ReactRedux template
This commit is contained in:
committed by
Steve Sanderson
parent
c791ceee49
commit
785e7d48a2
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user