Rubel Router
The simple router package for React with path-to-regexp.
Installation
npm install --save rubel-router
Get Started
routes.js
;;;;; const HomeComponent = <Home ...params/>;const DashboardComponent = <Dashboard ...params/>;const ProfileComponent = <Profile ...params/>;const PostComponent = <Post ...params/>; const routes = path: "/" action: HomeComponent path: "/dashboard" action: DashboardComponent path: "/profile" action: ProfileComponent path: "/post/:id" action: PostComponent ;
App.js
;;; { superprops; thisstate = 'url': '' // current url 'path': '' // current path ; thishandleRoute = thishandleRoute; } { // Update url info this; } { return <ReactFragment> <p>Current URL: thisstateurl</p> <p>Current Path: thisstatepath</p> /* Navigation */ <ul> <li> <Route path="/" text="Top" handleRoute=thishandleRoute/> </li> <li> <Route path="/dashboard" text="Dashboard" handleRoute=thishandleRoute/> </li> <li> <Route path="/profile" text="Profile" handleRoute=thishandleRoute/> </li> <li> <Route path="/post/9" text="Post-Id" handleRoute=thishandleRoute/> </li> </ul> /* Router Component */ <Router routes=routes info=thisstate/> </ReactFragment>; } ;
Example
cd rubel-router/example/
npm install
npm start
License
This project is licensed under the terms of the MIT license.
Author
bmf - A Web Developer in Japan.