diff --git a/src/App.js b/src/App.js index 0ab95061..9f11717e 100644 --- a/src/App.js +++ b/src/App.js @@ -1,20 +1,11 @@ -/* - * This component houses the routes of our app - * Routes determine the component to show when a url is visited - * - * Activity: - * Create an additional route that leads to another component. - * - * When your done, create a branch on our repository and push your code. :) - * - * Reference: https://reacttraining.com/react-router/core/guides/philosophy - */ import React, { Component } from "react"; import { BrowserRouter, Switch, Route } from "react-router-dom"; import Home from "components/Home/Home"; import Navbar from "components/Elements/Navbar/Navbar"; +import About from "components/About/About"; import ProfileCard from "components/Profile/ProfileCard"; import ProfileForm from "components/Profile/ProfileForm"; + class App extends Component { render() { return ( @@ -23,6 +14,7 @@ class App extends Component { + diff --git a/src/components/About/About.js b/src/components/About/About.js new file mode 100644 index 00000000..3375e4f6 --- /dev/null +++ b/src/components/About/About.js @@ -0,0 +1,14 @@ +import React from "react"; +import PageContent from "components/Elements/PageContent"; + +const About = () => { + return ( + + + ); +}; + +export default About; diff --git a/src/components/Profile/ProfileCard.js b/src/components/Profile/ProfileCard.js index 6c20514e..1bff0ab3 100644 --- a/src/components/Profile/ProfileCard.js +++ b/src/components/Profile/ProfileCard.js @@ -19,8 +19,8 @@ import PageContent from "components/Elements/PageContent"; const ProfileCard = () => { return (
diff --git a/src/components/Profile/ProfileForm.js b/src/components/Profile/ProfileForm.js index 9f6d1853..424debd0 100644 --- a/src/components/Profile/ProfileForm.js +++ b/src/components/Profile/ProfileForm.js @@ -1,24 +1,24 @@ -/* In this component, we'll handle forms. - * React handles forms quite differently. +/* In this component, we'll handle forms. + * React handles forms quite differently. * You'll need to handle the changes when you input something to the form. - * + * * Activity: - * Modify this component to create your form. + * Modify this component to create your form. * Add new fields, new form elements * Create a function that logs the form results. - * - * Reference: https://reactjs.org/docs/forms.html + * + * Reference: https://reactjs.org/docs/forms.html */ import React, { Component } from "react"; import PageContent from "components/Elements/PageContent"; +const defaultState = { name: "", message: "" }; + class ProfileForm extends Component { constructor(props) { super(props); - this.state = { - value: "" - }; + this.state = defaultState; /* If we don't bind the event handler method, * we'll get an error: "this" is undefined. @@ -27,20 +27,26 @@ class ProfileForm extends Component { this.handleSubmit = this.handleSubmit.bind(this); } - /* To be able to edit forms in React, - * you'll need to handle changes. + /* To be able to edit forms in React, + * you'll need to handle changes. * We'll create a function handleChange */ handleChange = event => { - this.setState({ value: event.target.value }); + const target = event.target; + + this.setState({ + [target.name]: target.value + }); }; /* Modify the function handleSubmit to log the form results. - * + * * You may also display the results in another component, * maybe to the ProfileCard component? :) */ handleSubmit = event => { + console.log(this.state); + this.setState(defaultState); event.preventDefault(); }; @@ -52,12 +58,22 @@ class ProfileForm extends Component { >
-