Should NavItem use <A> (router link) rather than <a> (HTML anchor)?
#416
LeoniePhiline
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi!
we‘ve had a bug with
NavItemseeming to work unreliably. As it turned out, we had the incorrect expectation that a link-NavItemwould act like a Leptos router link<A>. However,NavItemin fact renders as HTML anchor<a>.One of the behavior differences comes up when using nested
<Routes>:The Leptos router link component resolves the
hrefrelative to the parent route, while with the HTML anchor element, the browser uses the existing URL and has no knowledge about routes. This causes different resulting target navigation URLs depending on if the current url does or does not have a trailing slash.This observation made me consider that maybe
NavItemshould use<A>in thaw 0.5.What do you think? Is there any advantage at all in the use of the html anchor element rather than the routes-aware Leptos router component?
All reactions