美文网首页
redux 笔记

redux 笔记

作者: Lzzzzzq | 来源:发表于2017-04-14 17:02 被阅读0次

Store

  • Store 就是保存数据的地方。
  • 可以看作是一个容器。
  • 整个应用只能有一个 Store。

Redux 提供 createStore 这个函数,用来生成 Store。

import { createStore } from 'redux';
const store = createStore(fn);

上面代码中,createStore 函数接受另一个函数作为参数,返回新生成的 Store 对象。

State

  • Store对象包含所有数据。
  • 如果想得到某个时点的数据,就要对 Store 生成快照。这种时点的数据集合,就叫做 State。
  • 当前时刻的 State,可以通过store.getState()拿到。
import { createStore } from 'redux';
const store = createStore(fn);

const state = store.getState();

Redux 规定, 一个 State 对应一个 View。只要 State 相同,View 就相同。

相关文章

  • Redux 笔记一:简单串讲

    Redux 笔记一:简单串讲 React 笔记一:简单串讲 Redux 笔记一:简单串讲 介绍 Redux并不是R...

  • Redux初步理解

    Redux笔记 参考理解 Redux 中文文档Redux 阮一峰 严格的单向数据流是Rduex设计核心。 Redu...

  • Redux-saga

    Redux-saga学习笔记说到中间件Redux-saga之前不得不提一下Redux-thunk(详细请访问:ht...

  • redux and react-redux

    感谢react小书作者,看了三遍,对redux有了点了解,写下随手笔记。 redux: 一、createStore...

  • GraphQL笔记一:简单串讲

    GraphQL笔记一:简单串讲 React 笔记一:简单串讲 Redux 笔记一:简单串讲 当然GraphQL和R...

  • 详解react、redux、react-redux之间的关系

    本文介绍了react、redux、react-redux之间的关系,分享给大家,也给自己留个笔记,具体如下: Re...

  • 详解react、redux、react-redux之间的关系

    本文介绍了react、redux、react-redux之间的关系,分享给大家,也给自己留个笔记,具体如下: Re...

  • Redux笔记

    state值变了,但是组件没被渲染? reducer是一个纯函数,不能在reducer直接修改state。redu...

  • redux笔记

    Redux 要求 UI 的渲染组件都是纯组件,即不包含任何状态(this.state)的组件。 进行数据处理、并包...

  • Redux笔记

    学习目的 了解和熟练使用 Redux,能够在实际项目中运用。 学习方法:类比 VueX Redux 比...

网友评论

      本文标题:redux 笔记

      本文链接:https://www.haomeiwen.com/subject/ceuzittx.html