How to get the current path from route.tsx/layout
I'm creating a sidebar and need the path to style isActive on navlink. I want to avoid using useLocation on client to reduce flashing on refresh. I thought Route.path or Route.fullPath would be a good solution, but it outputs 'undefined' and '/' respectively even when I'm on different routes (children). In order to get the actual correct path, I need to go to the page itself and use Route.path, which is not ideal because sidebar is located in route.tsx(layout). Any suggestion on how I should proceed?
2 Replies
fascinating-indigo•6mo ago
can you please provide a minimal complete example on what you are trying to do here?
fair-roseOP•6mo ago
nevermind layout shift was a result of icons being loaded later. I can just use useLocation to get the current path from route.tsx