I completed the project and the video player works, it just won’t switch videos when I click the radio buttons. I’ve gone over the hints, watched the get unstuck video and tried to compare every line of my code to the demo video, I just can’t find any differences. I plugged all the code into sublime just to see if it would catch any little syntax errors, but also nothing. Using Firefox.
App.js
import React from "react";
import ReactDOM from "react-dom";
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",
};
class App extends React.Component {
constructor(props) {
super(props);
this.state = { src: VIDEOS.fast };
this.chooseVideo = this.chooseVideo.bind(this);
}
chooseVideo(newVideo) {
this.setState({
src: VIDEOS[newVideo]
});
}
render() {
return (
<div>
<h1>Video Player</h1>
<Menu chooseVideo={this.chooseVideo} />
<Video src={this.state.src} />
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById("app"));
Video.js
import React from 'react';
export class Video extends React.Component {
render() {
return (
<div>
<video controls autostart autoPlay muted src={this.props.src} />
</div>
);
}
}
Menu.js
import React from 'react';
export class Menu extends React.Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick(e) {
var text = e.target.value;
this.props.chooseVideo(text);
}
render() {
return (
<form onclick={this.handleClick}>
<input type="radio" name="src" value="fast" /> fast
<input type="radio" name="src" value="slow" /> slow
<input type="radio" name="src" value="cute" /> cute
<input type="radio" name="src" value="eek" /> eek
</form>
);
}
}