Last active
October 21, 2018 08:01
-
-
Save productioncoder/74a504174df760c6bb915a49b67be8e9 to your computer and use it in GitHub Desktop.
Youtube pull most popular videos into HomeContent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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