1.安装构建工具react
npm install -g create-react-app
webpack
2.构建项目web
create-react-app ProjectName
npm
3.安装reduxjson
npm install redux --save npm run eject 弹出配置文件 可自定义配置webpack
4.安装异步处理 redux-thunknpm install redux-thunk --save
使用applyMiddleware开启 thunk中间件redux
5.安装链接 react-redux npm install react-redux --save
React-redux 提供 Provider和connect 两个接口来链接
Provider组件在应用最外层,传入store便可,只用一次
Connect负责从外部获取组件所需的参数babel
6.安装装饰器 npm install babel-plugin-transform-decorators-legacy --save-dev
package.json 的 babel 中加入react-router
"plugins": [ "transform-decorators-legacy" ]
connect的使用变得简洁app
@connect( (state) => {{num: state}}, // 属性 { addGun, removeGun, addGunAsync } // 方法 )
7.React-Router 4npm install react-router-dom --save
dom