Skip to content

Instantly share code, notes, and snippets.

@kaleem-elahi
Created August 21, 2018 11:00
Show Gist options
  • Save kaleem-elahi/100e95e8eee632fc8054b6f437f44aa2 to your computer and use it in GitHub Desktop.
Save kaleem-elahi/100e95e8eee632fc8054b6f437f44aa2 to your computer and use it in GitHub Desktop.
redux-promise-middleware
// This file merely configures the store for hot reloading.
// This boilerplate file is likely to be the same for each project that uses Redux.
// With Redux, the actual stores are in /reducers.
import promiseMiddleware from 'redux-promise-middleware';
import { createStore, applyMiddleware, compose } from 'redux';
import thunkMiddleware from 'redux-thunk';
import rootReducer from './';
const createStoreWithMiddleware = compose(
applyMiddleware(
thunkMiddleware,
promiseMiddleware({ promiseTypeSuffixes: ['LOADING', 'SUCCESS', 'ERROR'] }),
),
window.devToolsExtension ? window.devToolsExtension() : f => f,
)(createStore);
export default function configureStore() {
const store = createStoreWithMiddleware(rootReducer, { Intl: { locale: (localStorage.getItem('currentLanguage') || 'en') } });
return store;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment