reactatouille
Version:
Reactatouille is a command-line tool to help quickly start and build a new React project, using Redux, Webpack, Gulp (You can add your own tasks, yo!), HMR/Hot Module Reload, Sass (architecture best practices), Jest, Enzyme, popmotion, Redux devtools (bro
27 lines (25 loc) • 891 B
JavaScript
import { browserHistory } from 'react-router'
import { createStore, applyMiddleware, compose } from 'redux'
import { routerMiddleware } from 'react-router-redux'
import rootReducer from './reducer'
import thunk from 'redux-thunk'
export default function configureStore (preLoadedState) {
const composeEnhancers = typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : compose
const enchancers = composeEnhancers(
applyMiddleware(thunk),
applyMiddleware(routerMiddleware(browserHistory))
)
const store = createStore(
rootReducer,
preLoadedState,
enchancers
)
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('./reducer', () => {
const nextRootReducer = rootReducer
store.replaceReducer(nextRootReducer)
})
}
return store
}