当前正在尝试将输入字段值等推入replyComments中,但是即使在分派此操作时它仍然为空。...reducer首先检查majorIndex,然后是minorIndex,从那里应该将其推入replyComments。谁知道我该如何解决?
case types.REPLY_COMMENT: {
return {
...state,
enableToggleComment: true,
imageData: state.imageData.map(image => image.id === action.majorIndex ?
{
...image,
comments: {
[action.minorIndex]: {
replyComments: [...image.comments.replyComments, { comment: action.newComment, likeComment: image.toggle, enableReply: false }]
}
}
} : image
)
}
}
使用
...
comments: {
[action.minorIndex]: {
replyComments: replyComments.concat([{ comment: action.newComment, likeComment: image.toggle, enableReply: false }])
}
}
...
可能有效,我猜可能是由于突变问题引起的