《Redux》

  • Redux is a predictable state container for JavaScript apps.

  • Keep your state flat.

  • Redux Flow


  • mutation and asynchronicity

  • Redux attempts to make state mutations predictable by imposing certain restrictions on how and when updates can happen.

  • To change something in the state, you need to dispatch an action. An action is a plain JavaScript object (notice how we don’t introduce any magic?) that describes what happened.

  • Finally, to tie state and actions together, we write a function called a reducer. Again, nothing magical about it—it’s just a function that takes state and action as arguments, and returns the next state of the app.

  • Three Principles

    1. Single source of truth (The state of your whole application is stored in an object tree within a single store.)
    2. State is read-only (The only way to change the state is to emit an action, an object describing what happened.)
    3. Changes are made with pure functions (To specify how the state tree is transformed by actions, you write pure reducers.)
  • Reducers are just pure functions that take the previous state and an action, and return the next state. Remember to return new state objects, instead of mutating the previous state.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 爱夜 夜是黑色的舞台 台上有鲜花 绿草 黑色的告白 台上有星星 月亮 黑色的云海 ...
    与美同行阅读 193评论 0 2
  • 清晨 我看到门前最美的野花 我撑着伞 迎着那微风携带的雨 嘴角皱起的皮肤 藏不住我内心的欢乐 我望着那不远处的枯藤...
    我想一个人走阅读 217评论 1 0
  • 也许我不应该这样海投一切我觉得有可能的,招应届生的工作。我不知道我这样的想法是不是对,但是我喜欢接触人的工作,喜欢...
    喜糖阅读 164评论 0 1
  • 有些人口若悬河的说,实事却不见一件!有一次从南京回来,我带了点货准备回来,可是觉得少了点,所以又通过找货软件,还准...
    人生如若如初见阅读 198评论 1 3