Skip to content

Instantly share code, notes, and snippets.

@lwcooper
Last active June 24, 2020 21:23
Show Gist options
  • Save lwcooper/a82719c253267a2dc1ade6f54d508f71 to your computer and use it in GitHub Desktop.
Save lwcooper/a82719c253267a2dc1ade6f54d508f71 to your computer and use it in GitHub Desktop.
react router
{/* A <Switch> looks through its children <Route>s and
renders the first one that matches the current URL. */}
<Switch>
<Route path="/about">
<About />
</Route>
<Route path="/users">
<Users />
</Route>
<Route path="/">
<Home />
</Route>
</Switch>
export default function App() {
return (
<Router>
<div>
// all my stuff
</div>
</Router>
);
}
import React from "react";
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment