这会被认为是 redux 中的纯 reducer 函数吗?

Will this be considered a pure reducer function in redux?

我有这个 reducer 函数,我在其中将 voteScore 的值递增 1。在不破坏 reducer 函数应该是纯函数的约束的情况下,这是正确的方法吗?

function comment (state = {}, action) {
 ...
 switch(action.type) {
 ...
  case UP_VOTE_COMMENT:
   const upVoteScore = parseInt(state[id]['voteScore'], 10) + 1

   return {
    ...state,
    [id]: {
     ...state[id],
     voteScore: upVoteScore
    }
   }
 }
}

是的。纯函数的思想是它总是根据输入产生相同的输出。

当前voteScore是参数中"input"的一部分。