我正在派遣一个行动:
removeAchievement(achievement){
this.props.removeAchievement({
type: 'REMOVE_ACHIEVEMENT',
id: this.props.day.id,
text: achievement,
})
}
行动创作者:
export const removeAchievement = (id, text) => ({ type: types.REMOVE_ACHIEVEMENT, id, text })
但是在我的reducer中,数据显示嵌套在我的id中:
如何阻止它嵌套?
答案 0 :(得分:2)
你的动作创建者期待一个id和文本,但是你用整个对象调用它 -
this.props.removeAchievement({
type: 'REMOVE_ACHIEVEMENT',
id: this.props.day.id,
text: achievement,
})
使用id和text调用它 -
this.props.removeAchievement(this.props.day.id, achievement);