Created
May 1, 2020 08:59
-
-
Save react-ram/e691f3b3d3df180e999158432100caf4 to your computer and use it in GitHub Desktop.
Basic React Router DOM Example - 1
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 from "react"; | |
import "./App.css"; | |
import { BrowserRouter as Router, Route, Switch, Link } from "react-router-dom"; | |
function LandingView() { | |
return <div>LandingView</div>; | |
} | |
function Login() { | |
return ( | |
<div> | |
Loginview | |
<p> | |
<Link to="/">back</Link> | |
</p> | |
</div> | |
); | |
} | |
function Register() { | |
return ( | |
<div> | |
Register view | |
<p> | |
<Link to="/">back</Link> | |
</p> | |
</div> | |
); | |
} | |
function App() { | |
return ( | |
<Router> | |
<div className="App"> | |
<div> | |
appbar{" "} | |
<p> | |
<Link to="/login">Login</Link> | |
</p> | |
<p> | |
<Link to="/register">Register</Link> | |
</p> | |
</div> | |
<div> | |
<Switch> | |
<Route path="/" exact> | |
<LandingView /> | |
</Route> | |
<Route path="/login"> | |
<Login /> | |
</Route> | |
<Route path="/register"> | |
<Register /> | |
</Route> | |
</Switch> | |
</div> | |
</div> | |
</Router> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment