Spotlighr Quiz

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 = "NTc3"
const videoHost= "https://videos.cdn.spotlightr.com/"
const iframeSrc = videoHost+"watch/quiz/"+ playerId
	
	React.useEffect(() => {
    const script = document.createElement('script');  
    script.src = videoHost + "assets/spotlightr.js"
    
    document.body.appendChild(script);
    return () => {
    	document.body.removeChild(script);
    }

    }, []);
  
  return (
  <iframe allow="autoplay" className="video-player-container spotlightr" data-playerid={playerId} allowtransparency="true" style={{maxWidth:'100%'}} name="videoPlayerframe" allowfullscreen="true" src={iframeSrc} frameborder="0" scrolling="no"> </iframe>      
    
    )
}

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