import { createStore, applyMiddleware } from 'redux'
import thunkMiddleware from 'redux-thunk'
import { createLogger } from 'redux-logger'
import { enableBatching } from 'redux-batched-actions'
import { routerMiddleware } from 'react-router-redux'

import rootReducer from '../reducers'

const loggerMiddleware = createLogger()
const enhancer = applyMiddleware(thunkMiddleware, loggerMiddleware)

export default (initialState) =>
    createStore(enableBatching(rootReducer), initialState, enhancer)
