一愕秫、添加依賴
1. yarn add redux react-redux redux-thunk react-router-dom
// redux-thunk 讓action可以返回函數的中間件
2. yarn add redux-logger --dev
//輔助redux,可在打印中看到redux一切行為和數據
二磷杏、創(chuàng)建項目目錄結構
目錄結構圖
三、配置Redux(<font color=#ff0000>文件具體路徑請看項目目錄結構</font>)
1. actionTypes 公用屬性
actionTypes公用type屬性
2. 添加一個action
action行為
3. 寫入與action對應的reducer
處理action傳來的信息
4. 合并reducer 凌摄,便于處理reducer過多導致的麻煩
合并Reducer
5. 配置store
配置store
-
將store寫入啟動程序中
添加store進根目錄index.js中 -
結束
三尿孔、配置路由
配置路由滞项,并且嘗試使用redux