disptach action error,值出现为嵌套对象

时间:2017-05-31 19:38:21

标签: reactjs redux

我正在派遣一个行动:

  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中:

enter image description here

如何阻止它嵌套?

1 个答案:

答案 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);