Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
valentinogiardino opened this issue Nov 14, 2023 · 1 comment
Open

Comments

@valentinogiardino
Copy link

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
Copy link

thesohailjafri commented May 20, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants