Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Youtube in React: dynamically creating video grids in Home Content
/*...*/
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
You can’t perform that action at this time.