createStore() 中将 Middleware 和 DevTools 一起使用
文章目录

createStore()中将Middleware和DevTools一起使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { createStore, applyMiddleware, compose } from 'redux'



const middleware = [ thunk ]
if (process.env.NODE_ENV !== 'production') {
middleware.push(createLogger())
}

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

const store = createStore(
reducer,
composeEnhancers(applyMiddleware(...middleware))
)