React redux

 

注意点一:

如果在reducer中使用,且xx或者yy是对象或者list

state.merge({xx: action.xx, yy: action.yy})

那么在使用时应该

const mapStateToProps = state => {
    let page = state.page;
    return {
        xx: page.getIn(['xx']).toJSON(),
        yy: page.getIn(['yy']).toJSON(),
    }
};

 

注意点二:

初始化map类型的state

const defaultState = fromJS({
    tagStatusList: {"ifPassTagChecked": true, "ifFailTagChecked": true, "ifSkipTagChecked": true}

});

export default (state = defaultState, action) => {
    switch (action.type) {
        case constants.CLICK_FILTER_CASE_STATUS_TAG:
            return state.set('tagStatusList', fromJS(action.tagStatusList));
        default:
            return state;
    }
}

const mapStateToProps = state => {
    let autoTestReport = state.autoTestReport;
    return {
        tagStatusList: autoTestReport.getIn(['tagStatusList']).toJSON(),
    }
};

 

posted @ 2019-05-13 10:48  小橙籽  阅读(138)  评论(0编辑  收藏  举报