React生态

一、Redux

1. 基本概念

  • store
  • state
  • action
  • reducer

2. 单项数据流

  • dispatch(action)
  • reducer -> newState
  • subscribe触发通知

3. react-redux

  • Provider
  • connect
  • mapStateToProps和mapDispatchToProps

4. 异步action

异步action中间件:

  1. redux-thunk
  2. redux-promise
  3. redux-saga

5. 中间件

6. 数据流图

5e6895d8f3139d71e1140454160c1362.png

二、react-router

  • 路由模式(hash、H5 history)
  • 路由配置(动态路由、懒加载)

参考 vue-router