Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.