组件之间数据传递
![](https://img.haomeiwen.com/i9470312/956d8c7b983bcfd7.png)
![](https://img.haomeiwen.com/i9470312/b43210475855f50c.png)
redux是js状态容器,提供可以预测的状态管理
react中安装
npm install --save redux
流程图:
![](https://img.haomeiwen.com/i9470312/ebe58a98209cdbee.png)
![](https://img.haomeiwen.com/i9470312/148d92049cbae67b.png)
![](https://img.haomeiwen.com/i9470312/ff3934e05f2e2cf5.jpg)
放在store文件夹下
index.js
![](https://img.haomeiwen.com/i9470312/94af9ed9ec4d1df7.png)
reducer.js
reducer是一个纯函数
![](https://img.haomeiwen.com/i9470312/6c9f5efecf5ccb35.jpg)
actionTypes.js
![](https://img.haomeiwen.com/i9470312/6e0f003cb3375e41.jpg)
actionCreator.js
![](https://img.haomeiwen.com/i9470312/eeaeb4162b6a88fc.jpg)
TestAntd.js调用store中的数据,并对数据list进行操作增加删除
store.subscribe()订阅,当store中的数据发生变化时,要调用方法更新组件中的state
![](https://img.haomeiwen.com/i9470312/0893e91d9a36fb2b.jpg)
![](https://img.haomeiwen.com/i9470312/ee33ea1444928716.jpg)
网友评论