Skip to content

react 中使用redux ​

本节目标:理解“react 中使用redux”的核心思路,并能把它用于实际开发或面试表达。 使用Redux流程

  1. 定义当前项目有什么功能(常量):actionTypes.js
const INCREMENT = 'increment';
const DECREMENT = 'decrement';
定义当前项目的默认状态,放到reducer中:reducer.js
let initialState = {
};
创建容器
let store = createStore(reducer)
可以在外面进行派发动作,默认渲染一次。

本站总访问 — 次