Skip to content

Instantly share code, notes, and snippets.

@productioncoder productioncoder/videos.js
Last active Nov 10, 2018

What would you like to do?
Youtube in React: related videos selector
const getRelatedVideoIds = (state, videoId) => {
const related = state.videos.related[videoId];
return related ? related.items : [];
export const getRelatedVideos = createSelector(
state => state.videos.byId,
(relatedVideoIds, videos) => {
if (relatedVideoIds) {
// filter kicks out null values we might have
return => videos[videoId]).filter(video => video);
return [];
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.