3-5-Middleware
console.log('prev state', store.getState())
store.dispatch(action)
console.log('next state', store.getState())const store = createStore(counter)
// 将原本的dispatch方法保留并附加上控制台输出的语句
let next = store.dispatch
store.dispatch = function dispatchAndLog(action) {
console.log('prev state', store.getState())
let result = next(action)
console.log('next state', store.getState())
return result
}Last updated