primefaces / sakai-react

Free React Admin Template
https://sakai.primereact.org
MIT License
885 stars 558 forks source link

How to set the AppMenuItem as active matching a dynamic route? #71

Open valentinogiardino opened 11 months ago

valentinogiardino commented 11 months ago

Hello,

I am currently working with Next.js and implementing dynamic routes, specifically exploring the use of optional catch-all segments, as documented here.

My question pertains to matching an AppMenuItem with a route structured like pages/shop/[[...slug]].js. I'm seeking guidance on how to dynamically set the AppMenuItem as active based on the current route.

Thank you for your assistance!

thesohailjafri commented 5 months ago

@valentinogiardino Hii

you would alter your logic here on line 19 of AppMenuItem const isActiveRoute = item!.to && pathname === item!.to

this currently match exact pathname but if you want to check lets say startWith or any custom logic, you would alter this line