Redux: ->?獨(dú)立的庫,非React項(xiàng)目也可使用;//Vuex必須在Vue項(xiàng)目中使用
1、npm install redux --save-dev;//同時(shí)Chrome下載React、Redux調(diào)試工具(翻墻)



補(bǔ)充:調(diào)試工具的使用


概述圖:

- - - >>>?優(yōu)化actionType、action、reducer、組件內(nèi)getState();dispatch();
2、actionTypes; actionCreator; combineReducers; react-redux//代碼管理維護(hù)
(1).actionTypes;//便于維護(hù)

?(2).actionCreators;//action進(jìn)行優(yōu)化 ->?接口暴露以函數(shù)的形式,因?yàn)橥饷嫘鑲魅雲(yún)?shù)

(3).combineReducers();//合并reducer, ->?使用其 -> 組件中獲取數(shù)據(jù):store.getState().xxx.xxx;


(4). react-redux;//其是一個(gè)連接react與redux的庫
[1].npm install react-redux --save-dev;//主要利用庫中的<Provider>組件,connect();

最終版:export default connect(mapStateToProps, actions)(TodoList);//只需寫mapStateToProps獲取state,dispatch系統(tǒng)通過actions自動(dòng)解決了,然后通過this.props.inpVal; this.props.changeVal();
