Forked from jaotors/gist:c5fba976d04f72844b8402490fbcdd39
Created
March 14, 2019 06:32
-
-
Save corysimmons/fd860f43b24e9bdb55005c997fc30eca to your computer and use it in GitHub Desktop.
ContentVideo.js
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
const ContentVideo = ({ videoId, on }) => { | |
const player = useRef(); | |
useEffect(() => { | |
player.current = new YTPlayer('#' + videoId); | |
player.current.load(videoId); | |
}, []); | |
useEffect(() => { | |
if (!on) { | |
player.current.pause(); | |
} | |
}, [on]); | |
return ( | |
<div | |
id={videoId} | |
css={` | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
border: 0; | |
`} | |
/> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment