Skip to content

Instantly share code, notes, and snippets.

@JonahTurnquist
Last active May 1, 2020 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonahTurnquist/02e830de17ee319d824455d3da8fe64b to your computer and use it in GitHub Desktop.
Save JonahTurnquist/02e830de17ee319d824455d3da8fe64b to your computer and use it in GitHub Desktop.
import React from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
// Layout
const Layout = ({ children }) => (
<div>
<header>My header</header>
{children}
<header>My footer</header>
</div>
);
// Pages
const PageA = () => <Layout>This is Page A</Layout>;
const PageB = () => <Layout>This is Page B</Layout>;
// Routes
export default function App() {
return (
<Router>
<Switch>
<Route path="/pageA" component={PageA} />
<Route path="/pageB" component={PageB} />
</Switch>
</Router>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment