28 lines
853 B
JavaScript
28 lines
853 B
JavaScript
import { createStore, applyMiddleware, compose } from 'redux';
|
|
import { syncHistoryWithStore } from 'react-router-redux'
|
|
import { hashHistory } from 'react-router'
|
|
import thunk from 'redux-thunk'
|
|
import { routerMiddleware } from 'react-router-redux'
|
|
|
|
// Import the root reducer
|
|
import rootReducer from './reducers/index'
|
|
|
|
const routingMiddleware = routerMiddleware(hashHistory)
|
|
|
|
const middlewares = [thunk, routingMiddleware];
|
|
|
|
// Only use in development mode (set in webpack)
|
|
if (process.env.NODE_ENV === `development`) {
|
|
const createLogger = require(`redux-logger`);
|
|
const logger = createLogger();
|
|
middlewares.push(logger);
|
|
}
|
|
|
|
// Export the store
|
|
const store = compose(applyMiddleware(...middlewares))(createStore)(rootReducer);
|
|
|
|
// Sync history with store
|
|
export const history = syncHistoryWithStore(hashHistory, store);
|
|
|
|
export default store;
|