Made with create-react-library
npm install --save clean-router
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>)
}
}
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
you can contribute to the utility as that will be greately appreciated.
MIT © gami34