• Redux:data flow


    我们使用react,是为了构建可复用的高性能的视图层,学习redux是为了处理视图组件中随应用复杂度提升而变得难以控制的state。说白了,是为了视图。

    在了解了action、reducer和store之后,文档并不继而介绍怎么应用到视图层,而是带我们先了解data flow这概念。

    react中data的传递经常是单向的,由上一级组件通过props传给子孙组件。

    redux的设计结构也是围绕着严格的单向数据流模式。

    This means that all data in an application follows the same lifecycle pattern, making the logic of your app more predictable and easier to understand.

    data lifecycle指的是redux应用的data lifecycle,不是react应用。

    data lifecycle想说的应该是redux的工作流程,也是 从action传入store-->返回新state的过程。

    xThe data lifecycle in any Redux app follows these 4 steps:

    1.调用store.dispatch(action)

    该方法是全局可用的。

    2.store调用传入createStore中的Reducer

        Reducer只用来生成新的state,且必须是可预测的,不应该有多余的操作。

    3.顶层的reducer把  子reducer返回的新state的各部分属性  组合起来,构成新的state。

    4.store保存 顶层Reducer返回的新state。

  • 相关阅读:
    C#带日期型默认值参数的函数
    mvc调用webapi上传图片或文件
    mysql增删改查存储过程
    sql 分页存储过程
    sql 出库存储过程
    Ternura
    留言板
    友链
    .net 死锁
    C#微信小程序搜索框
  • 原文地址:https://www.cnblogs.com/alan2kat/p/7501187.html
Copyright © 2020-2023  润新知