clean-router
v1.0.2
Published
cleaner way to declare routes in reactjs using the React-router-dom
Downloads
1
Maintainers
Readme
clean-router
Made with create-react-library
Install
npm install --save clean-router
Usage
import React, { Component } from 'react'
import { useCleanRouter } from 'clean-router'
class Example extends Component {
const [mainRouteHandler, subRouteHandler] = useCleanRouter(<Loader />)
render() {
return (
<Router>
{mainRouteHandler("/dash", <DashOutlet>, [
subRouteHandler("", <Home />), // /dash/
subRouteHandler("profile", <Profile />), // /dash/profile
subRouteHandler("email", <EmailOutlet />, [
subRouteHandler("", <Inbox />), // /dash/email
subRouteHandler("spam", <Spam />), // /dash/email/spam
]),
])}
</Router>)
}
}
Note
The utility can handle up to 4 level deep routes with param and text counting as one, e.g "user/:userId" is considered as a single count. also "acount/:accountId/:planId" is also a single count"
example of a 4 level deep routes as mentioned above /dash/account/credit/internal
Contributions and Suggestion
you can contribute to the utility as that will be greately appreciated.
License
MIT © gami34