Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active October 21, 2018 08:01
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/74a504174df760c6bb915a49b67be8e9 to your computer and use it in GitHub Desktop.
Save productioncoder/74a504174df760c6bb915a49b67be8e9 to your computer and use it in GitHub Desktop.
Youtube pull most popular videos into HomeContent
import {VideoGrid} from '../../../components/VideoGrid/VideoGrid';
import React from 'react';
import './HomeContent.scss';
import {getMostPopularVideos} from '../../../store/reducers/videos';
import {connect} from 'react-redux';
const AMOUNT_TRENDING_VIDEOS = 12;
class HomeContent extends React.Component {
render() {
const trendingVideos = this.getTrendingVideos();
return (
<div className='home-content'>
<div className="responsive-video-grid-container">
<VideoGrid title='Trending' videos={trendingVideos}/>
</div>
</div>
);
}
getTrendingVideos() {
return this.props.mostPopularVideos.slice(0, AMOUNT_TRENDING_VIDEOS);
}
}
function mapStateToProps(state) {
return {
mostPopularVideos: getMostPopularVideos(state),
};
}
export default connect(mapStateToProps, null)(HomeContent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment