CLOSER-Cohorts/archivist

View on GitHub
react/src/configureStore.js

Summary

Maintainability
A
0 mins
Test Coverage
import { createBrowserHistory } from 'history'
import { applyMiddleware, compose, createStore } from 'redux'
import { routerMiddleware } from 'connected-react-router'
import createRootReducer from './reducer'
import { promiseMiddleware, localStorageMiddleware } from './middleware';

export const history = createBrowserHistory()

export default function configureStore(preloadedState) {
  const store = createStore(
    createRootReducer(history), // root reducer with router state
    preloadedState,
    compose(
      applyMiddleware(
        routerMiddleware(history), // for dispatching history actions
        promiseMiddleware,
        localStorageMiddleware
        // ... other middlewares ...
      ),
    ),
  )

  return store
}