Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Youtube in React: channels reducer for WATCH_DETAILS_SUCCESS
function reduceWatchDetails(responses, prevState) {
const channelResponse = responses.find(response => response.result.kind === CHANNEL_LIST_RESPONSE);
let channels = {};
if (channelResponse && channelResponse.result.items) {
// we know that there will only be one item
// because we ask for a channel with a specific id
const channel = channelResponse.result.items[0];
channels[channel.id] = channel;
}
return {
...prevState,
byId: {
...prevState.byId,
...channels
}
};
}
export const CHANNEL_LIST_RESPONSE = 'youtube#channelListResponse';
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.