Skip to content

Instantly share code, notes, and snippets.

@jaotors
Created March 13, 2019 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jaotors/c5fba976d04f72844b8402490fbcdd39 to your computer and use it in GitHub Desktop.
Save jaotors/c5fba976d04f72844b8402490fbcdd39 to your computer and use it in GitHub Desktop.
ContentVideo.js
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