原创 redux(三)react-redux容器組件鏈接UI組件映射store中的state到props

cnpm i react-redux,然後在App.js中引入react-redux的Provider組件(react-redux的容器組件,始終在最外層),引入當前目錄下store下的store.js,將store傳遞給Provider

原创 redux(四)用redux-thunk和redux中間件發送異步action

cnpm i redux-thunk,然後在store文件中引入,同時解構出redux的applyMiddleware,將thunk傳入中間件,將中間件傳入store:import {createStore, applyMiddlewar