I use piral for our micro-frontend app. I created a layout and use things like <Menu>
in the layout.
I want to filter the entries in the nav menu by routes. Via convention i'll drop menu items depending on teh current route.
I only have one issue: how can I get access to the current route in the MenuContainer
?
function Menu(props: MenuContainerProps) {
const currentRoute = /* where to get it from?? */
return /* my code */;
}
THANKS!
Piral just uses
react-router-dom
under the hood. Actually, this gives you access to anything fromreact-router
andreact-router-dom
. As such hooks such asuseHistory
work in all components, e.g., yourLayout
,MenuContainer
, or in any component of some pilet.Example:
Hope that helps!