-
-
Save codecademydev/112593d199e7e37979e9a53349ba8b02 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) { | |
const newSrc = VIDEOS[newSpeed]; | |
setSrc(newSrc); | |
}; | |
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 controls autostart autoPlay muted src={props.src}/> | |
</div> | |
); | |
}; | |
export default Video; |
Thank you for your help 💯
You're welcome!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for your help 💯