【React】使用增強函數解決thunk中間件與redux-dev-tools都需要的問題

  1. 創建增強函數image.png
  2. 插入CreateStore方法image.png
const composeEnhancer=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE_?window.__REDUX_DEVTOOLS_EXTENSION__({}):compose
const enhancer=composeEnhancer(applyMiddleware(thunk))
const store=createStore(reducer,enhancer)
export default store

總結:增強函數相當於是兩個函數合併或者說是鏈式函數

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章