Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save corysimmons/fd860f43b24e9bdb55005c997fc30eca to your computer and use it in GitHub Desktop.
Save corysimmons/fd860f43b24e9bdb55005c997fc30eca 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