React Hooks Example: Timer

Simple React Hooks example. A timer that pauses when you hold the mouse button. Creates and uses a custom Hook.

by petarsubotic

HTML

<div id="app"></div>

CSS

.timer {
  padding: 20px;
  font-size: 40px;
}

React

function EmbedVideo () {
	const playerId = "MTg0Mw=="
  const videoHost= "https://videos.cdn.spotlightr.com/"
	React.useEffect(() => {
    const script = document.createElement('script');  
    script.src = videoHost + "assets/spotlightr.js"
    
    document.body.appendChild(script);
    return () => {
    	document.body.removeChild(script);
    }

    }, []);
  
  return (
  	<a className="channelIframe videoPlayer" href="" data-playerid={playerId}></a>
    
  )
}

ReactDOM.render(<EmbedVideo />, document.querySelector("#app"))