Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/acro5piano/onemile-router

A react router alternative
https://github.com/acro5piano/onemile-router

react react-router router

Last synced: 8 days ago
JSON representation

A react router alternative

Awesome Lists containing this project

README

        

[![npm version](https://badge.fury.io/js/onemile-router.svg)](https://badge.fury.io/js/onemile-router)

# Onemile router

A React Router alternative.

Onemile router provides dead simple and easy-to-manage routing.

![demo](https://github.com/acro5piano/onemile-router/blob/master/demo.gif)

# Install

```
npm install onemile-router
```

or if you use yarn:

```
yarn add onemile-router
```

# Example

Note: Onemile router have not published to NPM yet.

```ts
import * as React from 'react'
import { Router, Route } from 'onemile-router'

const Dashboard = () =>

Dashboard

const Message = () =>
Message

export default class App extends React.Component {
router: Router

onRouteChange = ({ from, to }) => {
console.log(from)
}

setRouter = (router: Router) => {
this.router = router
}

toDashboard = () => this.router.push('/')

toMessage = () => this.router.push('/message')

render() {
return (


Onemile router example




Dashboard
Message


)
}
}
```

# TODO

- [x] Publish to NPM
- [ ] Write test
- [ ] Route parameter
- [ ] Provide `withRouter()` HOC