reactjs - 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”还是两者兼而有之?
有什么不同?
解决方案
推荐阅读
- awk - 需要根据文件中的搜索模式删除换行符
- c - 错误:c 代码:表达式必须是可修改的左值
- php - 当我转到 wp-admin/admin-post.php 时如何调试 wordpress 白屏
- surge.sh - urge.sh - 推送新更改不会更新站点
- hadoop - NoClassDefFoundError:org/apache/hadoop/hbase/TableNotFoundException
- android - 为什么 WebGL 片段着色器在移动设备上会随着时间的推移而变慢?
- python - 如何在 Plotly-Dash (dbc.NavbarSimple) 中将徽标添加为品牌(或品牌名称)?
- getid3 - getID3 写入 ETCO 和 TCON 标签
- python - 编写一个名为 process_line 的函数,它接受一个非 -ve 整数作为输入。查找否。整数,它们的和和乘积并返回元组 (N,S,P)
- c++ - threadprivate 初始化函数范围的静态变量