Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Created December 17, 2018 16:04
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/dc542c3389747b991f629cf157032179 to your computer and use it in GitHub Desktop.
Save productioncoder/dc542c3389747b991f629cf157032179 to your computer and use it in GitHub Desktop.
Youtube in React: wiring Home component up with video categories
/*....*/
import {getVideoCategoryIds} from '../../store/reducers/videos';
/* ... */
function mapStateToProps(state) {
return {
youtubeLibraryLoaded: getYoutubeLibraryLoaded(state),
videoCategories: getVideoCategoryIds(state),
};
}
function mapDispatchToProps(dispatch) {
const fetchMostPopularVideos = videoActions.mostPopular.request;
const fetchVideoCategories = videoActions.categories.request;
const fetchMostPopularVideosByCategory = videoActions.mostPopularByCategory.request;
return bindActionCreators({fetchMostPopularVideos, fetchVideoCategories, fetchMostPopularVideosByCategory}, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(Home);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment