-
-
Save codecademydev/e9d2df521c32de118f731bddda5c7daa to your computer and use it in GitHub Desktop.
Codecademy export
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
import React, { useState } from 'react'; | |
import { createRoot } from 'react-dom/client'; | |
import Video from './Video'; | |
import Menu from './Menu'; | |
const VIDEOS = { | |
fast: 'https://content.codecademy.com/courses/React/react_video-fast.mp4', | |
slow: 'https://content.codecademy.com/courses/React/react_video-slow.mp4', | |
cute: 'https://content.codecademy.com/courses/React/react_video-cute.mp4', | |
eek: 'https://content.codecademy.com/courses/React/react_video-eek.mp4' | |
}; | |
function App() { | |
const [src, setSrc] = useState(VIDEOS.fast); | |
function onSelectVideoHandler(newSpeed) { | |
setSrc(VIDEOS[newSpeed]); | |
} | |
return ( | |
<div> | |
<h1>Video Player</h1> | |
<Menu onSelectVideo = {onSelectVideoHandler} /> | |
<Video src={src} /> | |
</div> | |
); | |
}; | |
const container = document.getElementById("app"); | |
const root = createRoot(container); | |
root.render(<App />); |
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
function Video(props) { | |
return ( | |
<div> | |
<video src={props.src} controls autostart autoPlay muted/> | |
</div> | |
); | |
}; | |
export default Video; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment