redux小结
1.創建reducers :保存初始化狀態。
2.入口文件通過redux 中的 { createStore } 將 reducers保存為快照,
通過react-redux中的{ Provider }組件中的store 屬性包裹共享狀態的組件。
3.使用共享狀態的組件通過react-redux中的 { connect } 訪問狀態,
通過connect的組件props上會掛在dispatch方法和共享的狀態,組件通過dispatch action將動作類型和參數發送給提前定義的actions,reducers匹配action的動作將action攜帶的參數更新state。
4.render函數中去調用this.setState是錯誤的。
5.一個組件中的所有子組件的render函數執行完畢后,子組件才一起連用componentDidMout。
6.操作Dom在componentDIdMout和componentDIdUpdata鉤子中。
7.componentWillReceiveProps:滿足組件中props發生變化條件才會觸發的鉤子,但是只要父組件觸發了render那么他的子組件都要經過一系列的鉤子函數,包括componentWillReceiveProps。
8.forceUpdate強制視圖更新。
9.使用dispatch路由onClick={ ()=> this.props.dispatch(routerRedux.push(/Detail/${record.primaryKey}))}。
10.使用dva@2.0 dispatch Promise。
轉載于:https://www.cnblogs.com/hideonbush/p/9375238.html
總結
- 上一篇: 命令执行顺序控制与管道
- 下一篇: Django的视图层简介