Last active
October 28, 2018 13:55
-
-
Save productioncoder/fb3763ce76ede872f8d602f1fe9a50ab to your computer and use it in GitHub Desktop.
Youtube get videos by category selector
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
export const getVideosByCategory = createSelector( | |
state => state.videos.byCategory, | |
state => state.videos.byId, | |
state => state.videos.categories, | |
(videosByCategory, videosById, categories) => { | |
return Object.keys(videosByCategory || {}).reduce((accumulator, categoryId) => { | |
const videoIds = videosByCategory[categoryId].items; | |
const categoryTitle = categories[categoryId]; | |
accumulator[categoryTitle] = videoIds.map(videoId => videosById[videoId]); | |
return accumulator; | |
}, {}); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment