mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 03:17:11 +00:00
Merge pull request #14660 from strapi/chore/add-redux-devtools
This commit is contained in:
commit
563fc9b967
@ -1,14 +1,29 @@
|
||||
import { createStore, applyMiddleware } from 'redux';
|
||||
import { createStore, applyMiddleware, compose } from 'redux';
|
||||
import createReducer from './createReducer';
|
||||
|
||||
const configureStore = (appMiddlewares, appReducers) => {
|
||||
let composeEnhancers = compose;
|
||||
|
||||
const middlewares = [];
|
||||
|
||||
appMiddlewares.forEach((middleware) => {
|
||||
middlewares.push(middleware());
|
||||
});
|
||||
|
||||
return createStore(createReducer(appReducers), {}, applyMiddleware(...middlewares));
|
||||
// If Redux Dev Tools are installed, enable them
|
||||
if (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
typeof window === 'object' &&
|
||||
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||
) {
|
||||
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({});
|
||||
}
|
||||
|
||||
return createStore(
|
||||
createReducer(appReducers),
|
||||
{},
|
||||
composeEnhancers(applyMiddleware(...middlewares))
|
||||
);
|
||||
};
|
||||
|
||||
export default configureStore;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user