state.js 617 B

123456789101112131415161718192021222324
  1. import { createStore, applyMiddleware } from "redux";
  2. import thunk from "redux-thunk";
  3. import createSagaMiddleware from "redux-saga";
  4. // import logger from "redux-logger";
  5. import saga from "../saga";
  6. import reducers from "../Reducers";
  7. const sagaMiddleware = createSagaMiddleware();
  8. const log = state => next => action => {
  9. console.log("PrevState", state.getState());
  10. next(action);
  11. console.log("action", action);
  12. console.log("nextState", state.getState());
  13. };
  14. export default createStore(
  15. reducers,
  16. // applyMiddleware(thunk, logger)
  17. applyMiddleware(thunk, sagaMiddleware, log)
  18. );
  19. sagaMiddleware.run(saga);