Guest User

Untitled

a guest
Mar 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. export const commentList = (state, action) => {
  2. switch (action.type) {
  3. case 'ADD_COMMENT':
  4. let newComment = { comment: action.data, id: +new Date };
  5. return state.concat([newComment]);
  6. case 'DELETE_COMMENT':
  7. let commentId = action.data;
  8.  
  9. default:
  10. return state || [];
  11. }
  12. }
  13.  
  14. case 'DELETE_COMMENT':
  15. const commentId = action.data;
  16. return state.filter(comment => comment.id !== commentId);
  17.  
  18. case 'DELETE_COMMENT':
  19. return state.filter(({ id }) => id !== action.data);
Add Comment
Please, Sign In to add comment