Created
December 17, 2018 16:16
-
-
Save productioncoder/33f271d44a31b7546dfbe10e19df1eaa to your computer and use it in GitHub Desktop.
Youtube in React: dynamically creating video grids in Home Content
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 {getMostPopularVideos, getVideosByCategory} from '../../../store/reducers/videos'; | |
class HomeContent extends React.Component { | |
/* ... */ | |
getVideoGridsForCategories() { | |
const categoryTitles = Object.keys(this.props.videosByCategory || {}); | |
return categoryTitles.map((categoryTitle,index) => { | |
const videos = this.props.videosByCategory[categoryTitle]; | |
// the last video grid element should not have a divider | |
const hideDivider = index === categoryTitles.length - 1; | |
return <VideoGrid title={categoryTitle} videos={videos} key={categoryTitle} hideDivider={hideDivider}/>; | |
}); | |
} | |
/* ... */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment