1.0.5 • Published 5 years ago

@yolajs/router v1.0.5

Weekly downloads
10
License
MIT
Repository
github
Last release
5 years ago

Small and efficient declarative routing for React.

Inspired by react-router and reach-router

Installation

npm install --save @yolajs/router

Usage

import { Case } from '@yolajs/router'

const App = () => (
  <div>
    <Case path="/" component={Home} />
    <Case path="/tag/:tag" component={Tag} />
    <Case path="/user/::userId" component={UserDetail} />
  </div>
)

const Home = () => <div>Home</div>
const Tag = ({tag}) => <div>Tag is a string: {tag}</div>
const UserDetail = ({userId}) => <div>userId is a Number: {userId}</div>

Documentation

<Case /> props

  • path: this is the path to match against the relative or absolute location. It is possible to match anything with *, any location segment with :param, or any number segment with ::param
  • component: the component to render if it is a match. It will be passed the

<Switch /> props

  • fallback
1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

1.0.2

5 years ago

1.0.0

5 years ago