Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Created November 10, 2018 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save productioncoder/78c2b41d16ca39247ae8e6b2b2609c06 to your computer and use it in GitHub Desktop.
Save productioncoder/78c2b41d16ca39247ae8e6b2b2609c06 to your computer and use it in GitHub Desktop.
Youtube in React: video details reducer
import {VIDEO_DETAILS, WATCH_DETAILS} from '../actions/watch';
/* ... */
export default function videos(state = initialState, action) {
switch (action.type) {
case MOST_POPULAR[SUCCESS]:
return reduceFetchMostPopularVideos(action.response, state);
case VIDEO_CATEGORIES[SUCCESS]:
return reduceFetchVideoCategories(action.response, state);
case MOST_POPULAR_BY_CATEGORY[SUCCESS]:
return reduceFetchMostPopularVideosByCategory(action.response, action.categories, state);
case WATCH_DETAILS[SUCCESS]:
return reduceWatchDetails(action.response, state);
case VIDEO_DETAILS[SUCCESS]:
return reduceVideoDetails(action.response, state);
default:
return state;
}
}
/* ... */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment