Added redux-logger

This commit is contained in:
Victor Perevertkin 2019-08-15 19:35:29 +03:00
parent aceb7cf635
commit 7bd218c3d6
No known key found for this signature in database
GPG Key ID: C750B7222E9C7830
2 changed files with 16 additions and 13 deletions

View File

@ -14,6 +14,7 @@
"react-tabs": "^3.0.0",
"reactstrap": "^8.0.0",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-saga": "^1.0.2"
},
"scripts": {

View File

@ -1,20 +1,22 @@
import { createStore, applyMiddleware, compose } from 'redux';
import rootReducer from '../reducers';
import createSagaMiddleware from 'redux-saga';
import logger from 'redux-logger';
import rootReducer from '../reducers';
import rootSaga from '../sagas';
const configureStore = () => {
const sagaMiddleware = createSagaMiddleware();
const store = createStore(
rootReducer,
window.__REDUX_DEVTOOLS_EXTENSION__
? compose(
applyMiddleware(sagaMiddleware),
window.__REDUX_DEVTOOLS_EXTENSION__()
)
: applyMiddleware(sagaMiddleware)
);
sagaMiddleware.run(rootSaga);
return store;
const sagaMiddleware = createSagaMiddleware();
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const middlewares = [sagaMiddleware];
if (process.env.NODE_ENV === 'development') {
middlewares.push(logger)
}
const store = createStore(rootReducer, undefined, composeEnhancers(applyMiddleware(...middlewares)));
sagaMiddleware.run(rootSaga);
return store;
};
export default configureStore;