UNPKG

badmfck-presenter

Version:

Wrapper for react-router-dom

37 lines (29 loc) 1.04 kB
# Presenter is a wraper over react-router-dom Create sitemap, setup presenter, navigate throught sitemap. # Sitemap is an instance of array, filled with INavigationPoint example: const sitemap=[ { name:"home", id:"/", sub:[ {name:"Contancts",id:"contacts"} {name:"Products",id:"products",sub:[ {name:"Product Details",id:"prod",path:"prod/:id"} ]} ] } ] # Use and update current site path useCurrentPath(); # Use and update menu (id: parent menu id) useMenu(id?:string) # Create router from sitemap, Oufift - react component with <Outlet> useCreateRouter=(sitemap:INavigationPoint[],Outfit:React.ReactElement,ErrorPage?:React.ReactElement,InnerErrorPage?:React.ReactElement) # Use presenter open access to navChange method - will change navigation by INavigationPoint or INavigationPoint.id export const usePresenter=():IUsePresenter=>{ return { navChange:navigationChange, navDisable:navigationPointDisable, } }