1.0.2 • Published 2 years ago

clean-router v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

clean-router

Made with create-react-library

NPM JavaScript Style Guide

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