What is the proper way to mark a Link current active page? #2408
-
For example, I have #[derive(Routable, PartialEq, Clone)]
enum Route {
#[at("/tagging")]
Tagging,
#[at("/new_tag")]
NewTag,
}
// Somewhere else
<Link<Route> classes={classes!("nav-link")} to={Route::Tagging}>{ "Tagging" }</Link<Route>>
// And
let yew_router::history::AnyLocation::Browser(active_page) = ctx.link().location().unwrap(); So now I have the |
Beta Was this translation helpful? Give feedback.
Answered by
voidpumpkin
Jan 25, 2022
Replies: 1 comment 6 replies
-
For function components simply use |
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
Magicloud
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For function components simply use
use_route
to get the current routeFor struct components its a bit complicated because you need to create a listener that would listen to route changes https://yew.rs/docs/concepts/router#struct-components-1