ux核心思路和代碼解析

最近在公司內(nèi)部培訓的時候,發(fā)現(xiàn)很多小伙伴只是會用redux、react-redux、redux-thunk的api,對于其中的實現(xiàn)原理和數(shù)據(jù)真正的流向不是特別的清楚,知其然,也要知其所以然,其實redux的源代碼非常簡介,下面逐一介紹,

1.先看一個簡單的redux應用的例子:

電腦培訓,計算機培訓,平面設計培訓,網(wǎng)頁設計培訓,美工培訓,Web培訓,Web前端開發(fā)培訓

import { createStore, combineReducers } from 'redux';

const year = (state, action) => {
    let defaultState = {
        year: 2017
    }
    state = state || defaultState;    switch (action.type) {        case 'add':            return {
                year: state.year + 1
            };            break;        case 'sub':            return {
                year: state.year - 1
            };            break;        default:    
        
		

網(wǎng)友評論