Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Youtube in React: get comments for video id selector
import {createSelector} from 'reselect';
/* ... */
const getCommentIdsForVideo = (state, videoId) => {
const comment = state.comments.byVideo[videoId];
if (comment) {
return comment.ids;
}
return [];
};
export const getCommentsForVideo = createSelector(
getCommentIdsForVideo,
state => state.comments.byId,
(commentIds, allComments) => {
return commentIds.map(commentId => allComments[commentId]);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.