React 单向数据流

React 单向数据流
React 单向数据流_第1张图片

redux中目录结构:


Actions

  • 声明action

Components

  • 创建component
  • 组合子component与container
  • 接收container传过来的属性

Containers

  • 引用component、action
  • 将action与state dispatch到component的props上

Reducers

  • 引入action
  • 初始化state
  • 定义action需要完成的具体动作
  • 更新state

Sagas

  • 引入action
  • 监听特定action
  • 异步按指定顺序执行action或自定义方法

Store

  • 引入reducer与middleware
  • 导出配置

index.js

  • 引入component、configureStore、saga
  • 通过configureStore创建store,runSaga
  • Provider 中赋值store
  • 渲染组件

你可能感兴趣的:(架构及设计模式)