0.0.1 • Published 9 years ago
rc-router v0.0.1
router
Router Component for react.
Design philosophy
- Keep it smiple, first match wins.
- Support nested routes.
- Easy to match url,
:nameto match named parameter,*matches everything remained. - Build in default IOS animation.
Install
npm i rc-routerUsage
import { Route, Link , Redirect } from 'rc-router';
let app = (
<Route path="/" component={Home}>
<Route path="/manage/*" component={Manage}/>
<Route path="/users" component={Users}>
<Route path="/users/:id" component={User}/>
</Route>
<Route path="/about" component={About}/>
<Route path="*" component={NotFound}/>
</Route>
)
ReactDOM.render(app , document.getElementById('app'))Props
| name | type | default | description |
|---|---|---|---|
| path | string | null | match role of path |
| component | func | null | shown component |
| onchange | func | null | path change event handler, for root route only |
Helper exports
Linkfor simple link with href for location redirectRedirectfunction called with path
Assigned props
Component rendered on route props would be assigned with additional props.
paramsobject contains all params (including query object).typerender type of component, could beparentchildsiblingenter.previousfunction for redirect to reasonable previous component.parentfunction for redirect to parent component.
License
MIT
0.0.1
9 years ago