Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/huang2002/hele-router

Declarative routing for hele.
https://github.com/huang2002/hele-router

3h declarative hash hele history link route router routing switch

Last synced: about 4 hours ago
JSON representation

Declarative routing for hele.

Awesome Lists containing this project

README

        

# hele-router

Declarative routing for hele.

# Usage

```jsx
// If you use this lib as a UMD module, please access the APIs via the `HEle` global.
import { HistoryRouter, HashRouter, Switch, Route, Link } from "hele-router";
import { render, createElement, Fragment } from "hele";

const Greeting = () =>

Welcome!

;

render(
(

{/* You can pass a `name` prop to a router to specify the name that it
stores itself in the context and pass the same value as `router` props
to links and routes to let them access that router. */}
{/* A history router uses the `history` APIs to route. It accepts a
`noHash` prop which is a boolean telling whether to preserve the hash
representing location. (Default: true) */}

My App


{/* matched = exact ? path === props.path : path.includes(props.path) */}
{/* Rendering priority: `component` > `render` > children */}
{/* `component` and children will only be rendered when matched. */}

matched &&

foo

} />

bar



{/* A link renders an anchor element. So, treat it as an anchor tag
except that you can set `back` to true to declare a back link. */}
Home
foo
bar
back

{/* A hash router uses the hash of the location to route. */}

{/* ... */}

{/* A switch router won't change the location of the document. It
stores its own location. So, it accepts a `path` prop representing
its default path. (Default: '/') */}

{/* ... */}


),
document.getElementById('root')
);
```

# Changelog

See [CHANGELOG.md](CHANGELOG.md)