#How do you handle active route states?

12 messages · Page 1 of 1 (latest)

pulsar smelt
#

What are the best practice to check which route is active?

#

How do you handle active route states?

atomic helm
#

depends on what for you need that information

#

give more context please

pulsar smelt
#

I have a sidebar and I want to add some highlighting on the sidebar items.
For example, home, posts, profile

If I navigate to profile/edit I want my profile item to be highlighted

#

I can do router.state.location.pathname.startsWith("/profile") and it seem to work

#

but how do I check dynamic routes like /profile/$username/edit?

#

Is there a way to do so, or do I have to parse the username in the string before checking?

#

like: router.state.location.pathname.startsWith(/profile/${usernameVar}/edit)

atomic helm
#

router.state.matches is typesafe

pulsar smelt
atomic helm
#

uses same data yes