Created
October 25, 2018 21:23
-
-
Save ryanflorence/d659b7be29d111550fb5421b80bcef2d to your computer and use it in GitHub Desktop.
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 { | |
useRouter, | |
Link | |
} from "@reach/router/unstable-hooks"; | |
function Accounts() { | |
let route = useRouter({ | |
".": () => <div>boring Accounts</div>, | |
dope: () => <div>Dope Accounts</div> | |
}); | |
return ( | |
<div> | |
<h2>Accounts</h2> | |
<nav> | |
<Link to="/accounts">Accounts Home</Link> •{" "} | |
<Link to="/accounts/dope"> | |
Dope Accounts | |
</Link> | |
</nav> | |
{route} | |
</div> | |
); | |
} | |
function App() { | |
let route = useRouter({ | |
".": () => <div>Home</div>, | |
"invoice/:invoiceId": ({ invoiceId }) => ( | |
<div>Invoice {invoiceId}</div> | |
), | |
"accounts/*": () => <Accounts /> | |
}); | |
return ( | |
<div style={{ padding: 20 }}> | |
<nav> | |
<Link to="/">Home</Link> •{" "} | |
<Link to="/accounts">Accounts</Link> •{" "} | |
<Link to="/invoice/123">Invoice 123</Link> •{" "} | |
<Link to="/accounts/dope"> | |
Dope Accounts | |
</Link> | |
</nav> | |
<hr /> | |
<main tabIndex="-1"> | |
{route} | |
</main> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment