Created
March 25, 2018 20:28
-
-
Save alexnm/b1f0b9916fd8ccc2f4946de287b0618a to your computer and use it in GitHub Desktop.
Basic layout with Routes
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 { Link, Switch, Route } from "react-router-dom"; | |
import Home from "./Home"; | |
import About from "./About"; | |
import Contact from "./Contact"; | |
export default class Layout extends React.Component { | |
/* ... */ | |
render() { | |
return ( | |
<div> | |
<h1>{ this.state.title }</h1> | |
<div> | |
<Link to="/">Home</Link> | |
<Link to="/about">About</Link> | |
<Link to="/contact">Contact</Link> | |
</div> | |
<Switch> | |
<Route path="/" exact component={ Home } /> | |
<Route path="/about" exact component={ About } /> | |
<Route path="/contact" exact component={ Contact } /> | |
</Switch> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment