【发布时间】:2020-01-28 17:04:48
【问题描述】:
pin = [
{
"id": 26,
"comments": [
{
"id": 2,
"username": "user",
"description": "example",
"pin": 26,
"commenter": 1
},
{
"id": 3,
"username": "admin",
"description": "example",
"pin": 26,
"commenter": 17
}
],
}
]
用户会发布一条新评论,我希望它在 cmets 数组下添加新评论 我试过这样写,但其他值变成空白
case ADD_COMMENT:
return {
...state,
pin: [...state.pin.commentstory, action.payload]
};
如何向 cmets 数组添加新值?
【问题讨论】:
-
我想你想要
pin: [...state.pin, action.payment]
标签: javascript arrays json reactjs redux