You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The package is distributed using npm, the node package manager.
npm i --save @lomray/react-route-manager
Usage
import{Manager}from'@lomray/react-route-manager';importtype{RouteObject}from'react-router';/** * Application URL manager */constmanager=newManager({routes: {home: {url: '/',},details: {url: '/details',children: {user: {url: '/user/:id',params: {id: ''},// id required param},},},about: {url: '/about',},},});/** * Now we can use it for get routes path for react-router */constroutes: RouteObject[]=[{path: manager.path('home'),lazy: ()=>import('@pages/home'),},{path: manager.path('details'),children: [{index: true,lazy: ()=>import('@pages/details'),},{path: manager.path('details.user'),lazy: ()=>import('@pages/details/user'),},],},{path: manager.path('about'),lazy: ()=>import('@pages/about'),},];/** * Also we can use it for generate url's */constMyComponent=()=>{return(<><Linkto{manager.makeURL('home')}>Homepage</Link><Linkto{manager.makeURL('about')}>Aboutpage</Link><Linkto{manager.makeURL('details')}>Detailspage</Link><Linkto{manager.makeURL('details.user',{id: 1})}>Userpage</Link></>)}