
*这里以redux-thunk为例:
cnpm install react-thunk --saveimport {
    createStore,
    applyMiddleware
} from "redux"
// 使用中间件的步骤1
import logger from "redux-logger"
import thunk from "redux-thunk"
import {
    deflate
} from "zlib";
const counterRdeux = (state = 0, action) => {
    switch (action.type) {
        case "add":
            return state + 1;
        case "minus":
            return state - 1;
        default:
            return state
    }
}
// 使用中间件的步骤2
const store = createStore(counterRdeux, applyMiddleware(logger, thunk))
export default store; const mapDispatchToProps = {
  add: ()=> ( { type:"add"}),
  minus: ()=> ({ type: "minus"}),
  // return 一个函数就是异步操作
  asyncAdd: () =>dispatch=> {
    setTimeout(()=> {
      dispatch({ type:  "add"})
    },1500) 
  }
}