相关疑难解决方法(0)

正确使用减速器

我不明白减压器是什么意思.如果我有2个包含相同动作的reducer功能,它是否可以使用?

function reducerA(state, action){
   switch(action.type):
       ...
       case 'SAME_ACTION': {...state, field: state.field+1}
}

function reducerB(state, action){
   switch(action.type):
       ...
       case 'SAME_ACTION': {...state, field: state.field*2}
}
Run Code Online (Sandbox Code Playgroud)

所以,如果我调用并且调用reduceReducer了动作"SAME_ACTION",那么我会有下一个状态吗?reducerAreducerB{field: 0}{field: 2}

在我看来,它有点连接缩减器(意味着将它们合并在一个键下).

我是对的还是reduceReducer服务于不同的目的?

reducers redux

31
推荐指数
1
解决办法
2万
查看次数

标签 统计

reducers ×1

redux ×1