Created
May 27, 2018 23:46
-
-
Save download13/d65a50a90b2cc44041ea50c6c4f296ab to your computer and use it in GitHub Desktop.
hyperapp router test case
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
<!DOCTYPE html> | |
<body> | |
<script src="index.jsx"></script> | |
</body> |
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 { app, h } from 'hyperapp'; | |
import { Switch, Route, Link, location } from '@hyperapp/router'; | |
const | |
Index = () => | |
<div> | |
Index | |
<Link to="/page">Page</Link> | |
</div>, | |
NotFound = () => (state, {location}) => | |
<div> | |
Not Found | |
</div>, | |
Page = () => | |
<div> | |
<Link to="/">Index</Link> | |
Page | |
<Link to="/broken">Broken</Link> | |
</div> | |
const view = () => | |
<Switch> | |
<Route path="/" render={ Index } /> | |
<Route path="/page" render={ Page } /> | |
<Route render={ NotFound } /> | |
</Switch>; | |
app({ | |
location: location.state | |
}, { | |
location: location.actions | |
}, | |
view, | |
document.body | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment