Last active
March 3, 2019 10:00
-
-
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
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 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