Created
April 3, 2019 01:57
-
-
Save kawnayeen/8ff45517afad605a0bf31574f23b1343 to your computer and use it in GitHub Desktop.
Enhanced Youtube # 5 - Video Details
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
// 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