Skip to content

Instantly share code, notes, and snippets.

@productioncoder productioncoder/Home.js
Last active Oct 29, 2018

Embed
What would you like to do?
Youtube Home feed infinite scroll
import {getVideoCategoryIds, videoCategoriesLoaded, videosByCategoryLoaded} from '../../store/reducers/videos';
/* ... */
class Home extends React.Component {
render() {
return (
<React.Fragment>
<SideBar/>
<HomeContent
bottomReachedCallback={this.bottomReachedCallback}
showLoader={this.shouldShowLoader()}/>
</React.Fragment>
);
}
/* ... */
bottomReachedCallback = () => {
if (!this.props.videoCategoriesLoaded) {
return;
}
this.fetchVideosByCategory();
};
shouldShowLoader() {
if (this.props.videoCategoriesLoaded && this.props.videosByCategoryLoaded) {
return this.state.categoryIndex < this.props.videoCategories.length;
}
return false;
}
}
function mapStateToProps(state) {
return {
youtubeLibraryLoaded: getYoutubeLibraryLoaded(state),
videoCategories: getVideoCategoryIds(state),
videoCategoriesLoaded: videoCategoriesLoaded(state),
videosByCategoryLoaded: videosByCategoryLoaded(state),
};
}
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.