安装

npm install --save redux

如果使用react

npm install --save react-redux

目录结构

redux 总结篇_目录结构

理解

1、actions 目录下的 index.js 存放了各个 action 的定义,并单个导出,给组件引用

2、containers 目录下的组件 引用某个 action,使用 dispatch 触发该 action

3、reducers 目录下的文件通过判断 action type 捕获触发的 action,然后更新 state 

4、redux 的 connect 的作用是把一个本来跟store无关的组件变为一个有关的组件,它的参数需要注意