Learn how to use the that comes with React Redux instead of the hand-rolled implementation from the previous lesson. Code to be refactored: class VisibleTodoList extends Component { componentDidMount() { const { store } = this.context; this.unsubscri…
Redux 原理 1. 单一数据源 all states ==>Store 随着组件的复杂度上升(包括交互逻辑和业务逻辑),数据来源逐渐混乱,导致组件内部数据调用十分复杂,会产生数据冗余或者混用等情况. Store 的基本思想是将所有的数据集中管理,数据通过 Store 分类处理更新,不再在组件内放养式生长. 2. 单向数据流 dispatch(actionCreator) => Reducer => (state, action) => state 单向数据流保证了数据的变化是有…