static-cms/src/store/configureStore.js

28 lines
877 B
JavaScript
Raw Normal View History

2016-02-25 00:45:56 -08:00
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
import thunkMiddleware from 'redux-thunk';
import { browserHistory } from 'react-router';
import { syncHistory, routeReducer } from 'react-router-redux';
import { auth } from '../reducers/auth';
2016-02-25 00:45:56 -08:00
import { config } from '../reducers/config';
import { entries } from '../reducers/entries';
import { entryDraft } from '../reducers/entryDraft';
2016-02-25 00:45:56 -08:00
import { collections } from '../reducers/collections';
const reducer = combineReducers({
auth,
2016-02-25 00:45:56 -08:00
config,
collections,
entries,
entryDraft,
2016-02-25 00:45:56 -08:00
router: routeReducer
});
const createStoreWithMiddleware = compose(
applyMiddleware(thunkMiddleware, syncHistory(browserHistory)),
window.devToolsExtension ? window.devToolsExtension() : (f) => f
)(createStore);
export default (initialState) => (
createStoreWithMiddleware(reducer, initialState)
);