這是我的初始狀態常量對象,我試圖將新的註釋項添加到註釋中,但此代碼不會將我的對象推入其中,提前。如何使用反應將對象推入數組
export const comments = [];
export const BlogPostReducer = (state = comments, action) => {
switch (action.type) {
case 'ADD_COMMENT':
return [
...state,
{
name: action.comment.name,
subject: action.comment.subject,
message: action.comment.message
}
];
default:
return state;
}
};
after i used see console here...still im getting empty state
@Hana Alaydrus你能幫助我在此 – kumar