reactjs - 如何在 React Redux 中将多个调度操作映射到单个道具
问题描述
按下提交按钮时,我需要调度两个动作。
const mapDispatchToProps = dispatch => ({
onSubmitPressed: countryCode => dispatch(createCountry(countryCode)),
onSubmitPressed: countryCode => dispatch(loadCountry(countryCode)),
});
上面的代码有效,但给出了警告
重复键“onSubmitPressed”
如何修改代码以将两个调度操作映射到单个道具而不复制密钥。
解决方案
const mapDispatchToProps = dispatch => ({
onSubmitPressed: countryCode => {
dispatch(createCountry(countryCode));
dispatch(loadCountry(countryCode));
}
});
推荐阅读
- java - 如何使用实时数据编辑视图模型/存储库中的条目
- c++ - 返回对局部变量的引用的问题...?
- c# - 远端没有完成握手就关闭了websocket连接
- list - 如何根据相似的值对列表进行分组
- python - Python + KivyMD 和代码优化上的小部件之间的交互和删除
- php - VSCode + Lando:Xdebug 不会停止
- reactjs - React-Redux Redux Action 被多次调用
- python - numpy中的3d矩阵乘法
- xcode - 为 iOS Simulator-i386 构建 Nativescript,但尝试链接为 iOS Simulator-x86_64 构建的文件
- javascript - 日志中的 ValidationError 项