작성
·
202
0
reducer code
case ADD_COMMENT_SUCCESS: {
const postIndex = state.mainPosts.findIndex(v => v.id === action.data.postId);
const post = state.mainPosts[postIndex];
const Comments = [...post.Comments, action.data.comment];
const mainPosts = [...state.mainPosts];
mainPosts[postIndex] = { ...post, Comments };
return {
...state,
isAddingComment: false,
mainPosts,
commentAdded: true,
};
}
const Comments = [...post.Comments, action.data.comment];
git: https://github.com/hyunsokstar/node_bird_33
https://github.com/hyunsokstar/node_bird_33/blob/master/front/reducers/post.js
https://github.com/hyunsokstar/node_bird_33/blob/master/front/components/PostCard.js
에러가 발생하는 이유를 몰겠어요
const postIndex = state.mainPosts.findIndex(v => v.id === action.data.postId);
에
아이디가 없나 해서 찾아봤는데 그것도 아닌거 같아요