首页 > 解决方案 > Redux action 的 as function 或 as constants 有什么区别

问题描述

我学习 Redux 并想知道这两种创建动作的方式(Action Creators)

NR:1

export function itemsIsLoading(bool) {
    return {
        type: 'ITEMS_IS_LOADING',
        isLoading: bool
    };
}

NR2

const saveUserFailure = errMsg => ({
    type: 'SAVE_USER_FAILURE',
    payload: errMsg,
});

我读到 Redux Thunk 需要该function版本,但我也看到了const使用该版本的示例?

Thunk 减速器是 NR1 版本吗?
和 Redux 基本减速器的 NR2?
NR1 版本是“Action Creators”还是两者兼而有之?

有什么不同?

标签: reactjsreduxredux-actions

解决方案


推荐阅读