reactjs - 在 redux 存储更改后,React 组件没有重新渲染和更新
解决方案
const userReducer = (state=initialState, actions) => {
switch(actions.type) {
case UPDATE_USERS:
return {...state, users: [...actions.payload.users]}
default:
return {...state}
}
}
在 react reducer 中,对于数组使用[...Array],对于对象使用 {...object}
推荐阅读
- java - 如何在没有并行包袱的情况下使用 Java reduce 将集合简化为对象?
- javascript - 我应该如何着手开发手机游戏?
- javascript - 用于在折线图中生成路径的 D3js 比例转换不起作用
- javascript - php里面的js条件
- pandas - pandas get_loc函数的向量化
- spring-boot - 从弹簧安全中删除过滤器
- angular - 我正在尝试在角度 js 中显示 keyName 、 Keyless 和 Keypresent 对象数组的模式,但它不起作用
- python - 无法安装 spyder 以在 Manjaro 上运行
- php - 共享主机中的 Laravel 7.x 托管问题
- python-3.x - 如何使用 python3 pandas 数据帧执行广度优先搜索