Created
February 15, 2019 12:01
-
-
Save dsc712/463f5cc96791753732295ae0bb05e974 to your computer and use it in GitHub Desktop.
Video List Detail
This file contains hidden or 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, { Component } from 'react'; | |
import { Icon } from "antd"; | |
class VideoDetail extends Component { | |
state = { | |
video: null | |
}; | |
componentDidUpdate(prevProps) { | |
if( this.props.video && ( prevProps.video !== this.props.video) ) { | |
this.setState({ video: this.props.video }) | |
} | |
} | |
render() { | |
const video = this.state.video; | |
if( !video ) { | |
return ( | |
<div style={{ "width": "67.5%", "background": "#999999", "color": "#fff", "height": "85vh", "postion": "relative" }}> | |
<h1 style={{ "top":"50%", "left": "28%", "position": "absolute" }}><Icon type={"youtube"}/></h1> | |
</div> | |
) | |
} | |
const videoId = video.id.videoId; | |
const url = `https://www.youtube.com/embed/${ videoId }`; | |
return ( | |
<div> | |
<div className={"embed-responsive embed-responsive-16by9"}> | |
<iframe title={ video.snippet.title } className={"embed-responsive-item"} src={url} allowFullScreen /> | |
</div> | |
<div> | |
<h2> | |
{ video.snippet.title } | |
</h2> | |
<div> | |
{ video.snippet.description } | |
</div> | |
</div> | |
</div> | |
) | |
} | |
} | |
export default VideoDetail; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment