Skip to content

Instantly share code, notes, and snippets.

@kawnayeen
Created April 3, 2019 01:57
Show Gist options
  • Save kawnayeen/8ff45517afad605a0bf31574f23b1343 to your computer and use it in GitHub Desktop.
Save kawnayeen/8ff45517afad605a0bf31574f23b1343 to your computer and use it in GitHub Desktop.
Enhanced Youtube # 5 - Video Details
// step one
const VideoDetail = ({video}) => {
console.log("called here: "+video);
if(!video) {
return <div>Loading...</div>
}
const videoId = video.id.videoId;
const url = `https://www.youtube.com/embed/${videoId}`;
let {title, description} = video.snippet;
return (
<div className="video-detail col-md-8">
<div className="embed-responsive embed-responsive-16by9">
<iframe className="embed-responsive-item" src={url}></iframe>
</div>
<div className="details">
<div>{title}</div>
<div>{description}</div>
</div>
</div>
);
};
//at app.js
render() {
return (
<div>
<SearchBar onSearchTermChange={this.onSearchTermChange}/>
<VideoDetail video={this.state.selectedVideo}/>
<VideoList videos={this.state.videos}/>
</div>
);
}
//set two -- set selected video at state
if(this.state.selectedVideo === null){
this.setState({
selectedVideo : videos[0]
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment