Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Youtube in React: video details and related videos
function reduceWatchDetails(responses, prevState) {
const videoDetailResponse = responses.find(r => r.result.kind === VIDEO_LIST_RESPONSE);
// we know that items will only have one element
// because we explicitly asked for a video with a specific id
const video = videoDetailResponse.result.items[0];
const relatedEntry = reduceRelatedVideosRequest(responses);
return {
...prevState,
byId: {
...prevState.byId,
[video.id]: video
},
related: {
...prevState.related,
[video.id]: relatedEntry
}
};
}
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.