Created
November 13, 2019 08:07
-
-
Save novonimo/58dc7355fca8b9447a7666ca29bc5a78 to your computer and use it in GitHub Desktop.
reducerSnippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case VOTE_COMMENT_SUCCESS: | |
return { | |
...state, | |
comments: state.comments.map(comment => | |
comment.id === action.id | |
? { | |
...comment, | |
cached_votes_up: action.data.vote_up, | |
cached_votes_down: action.data.vote_down, | |
} | |
: comment.children[0]?.id === action.id | |
? { | |
...comment, | |
children: [ | |
{ | |
...comment.children[0], | |
cached_votes_up: action.data.vote_up, | |
cached_votes_down: action.data.vote_down, | |
}, | |
], | |
} | |
: comment | |
), | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment