You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<Link /> and <NavLink /> are not scrolling the page. Rather they treat this argument: #section2 as an absolute path and compile to <a href="/#section2"> that prevents the default behavior of anchor tag, that is to scroll the page to element with id=section2.
Similarly, navigate(#section2) is also not scrolling the page and leaving the page as it is.
The text was updated successfully, but these errors were encountered:
I'm using React Router as a...
library
Reproduction
Default Behavior that scrolls to an element with id=section2:
<a href="#section2">Scroll to Section 2</a>
window.location.assign("#section2")
window.location.replace("#section2")
React Router methods that does not scroll the page to element with id=section2:
<Link to="#section2">Scroll to Section 2<Link> //Does not mimic the natural behavior like anchor <a/> tag
<NavLink to="#section2">Scroll</NavLink> //Does not mimic the natural behavior like anchor <a/> tag
System Info
Used Package Manager
npm
Expected Behavior
All of the following should scroll to the element with id="section":
<Link to="#section">Scroll</Link>
<NavLink to="#section">Scroll</NavLink>
Actual Behavior
<Link />
and<NavLink />
are not scrolling the page. Rather they treat this argument:#section2
as an absolute path and compile to<a href="/#section2">
that prevents the default behavior of anchor tag, that is to scroll the page to element with id=section2.Similarly,
navigate(#section2)
is also not scrolling the page and leaving the page as it is.The text was updated successfully, but these errors were encountered: