Skip to content

Instantly share code, notes, and snippets.

@download13
Created May 27, 2018 23:46
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 download13/d65a50a90b2cc44041ea50c6c4f296ab to your computer and use it in GitHub Desktop.
Save download13/d65a50a90b2cc44041ea50c6c4f296ab to your computer and use it in GitHub Desktop.
hyperapp router test case
<!DOCTYPE html>
<body>
<script src="index.jsx"></script>
</body>
import { app, h } from 'hyperapp';
import { Switch, Route, Link, location } from '@hyperapp/router';
const
Index = () =>
<div>
Index&nbsp;
<Link to="/page">Page</Link>
</div>,
NotFound = () => (state, {location}) =>
<div>
Not Found
</div>,
Page = () =>
<div>
<Link to="/">Index</Link>&nbsp;
Page&nbsp;
<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