npm.io
1.1.20 • Published 9 years ago

inferno-route

Licence
—
Version
1.1.20
Deps
0
Vulns
0
Weekly
0

inferno-route

Another routing library for Inferno.

  • Incredibly lightweight (with only 1 component Route)
  • TypeScript friendly

Installation

npm install --save inferno-route

Usage

import Component from "inferno-component"
import Route from "inferno-route"

class User extends Component<any, {}> {
    render() {
        return this.props.params.id
    }
}

// Set your entry point, like "#/", "#/1/2", "#/users/wizawu"
if (!window.location.hash) window.history.replaceState(null, null, "#/")

Inferno.render((
    <Route path="#" component={Root}>
        <Route path="1" component={First}>
            <Route path="2" component={Second}>
                <Route path="3" component={Third} />
            </Route>
        </Route>
        <Route path="users/:id" component={User} />
        <Route path="profile/.*" component={Profile} />
    </Route>
), document.body.firstChild)
Issues

Please email to wizawu@gmail.com. Open source soon.