Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active March 3, 2019 10:00
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/412e6a5d327460fbb7abaf61e5dcffef to your computer and use it in GitHub Desktop.
Save productioncoder/412e6a5d327460fbb7abaf61e5dcffef to your computer and use it in GitHub Desktop.
Youtube in React: pull in total amount of comments for a specific video
/* ... */
import React from 'react';
import {Video} from '../../../components/Video/Video';
import {VideoMetadata} from '../../../components/VideoMetadata/VideoMetadata';
import {VideoInfoBox} from '../../../components/VideoInfoBox/VideoInfoBox';
import {Comments} from '../../Comments/Comments';
import {RelatedVideos} from '../../../components/RelatedVideos/RelatedVideos';
import './WatchContent.scss';
import {getAmountComments, getRelatedVideos, getVideoById} from '../../../store/reducers/videos';
import {connect} from 'react-redux';
import {getChannel} from '../../../store/reducers/channels';
import {getCommentsForVideo} from '../../../store/reducers/comments';
import {InfiniteScroll} from '../../../components/InfiniteScroll/InfiniteScroll';
export WatchContent extends React.Component {
render() {
{/*...*/}
<Comments comments={this.props.comments} amountComments={this.props.amountComments}/>
{/*...*/}
}
}
function mapStateToProps(state, props) {
return {
video: getVideo(state, props),
relatedVideos: getRelatedVideos(state, props.videoId),
comments: getCommentsForVideo(state, props.videoId),
channel: getChannel(state, props.channelId),
commentNextPageToken: getCommentNextPageToken(state, props),
amountComments: getAmountComments(state, props.videoId)
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment