-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Closed
Closed
Copy link
Labels
Description
What version of React Router are you using?
6.10.0
Steps to Reproduce
Example app.
https://codesandbox.io/s/crimson-cdn-n3gpdq?file=/src/App.js
Create broserRouter and following route
import { Link } from "react-router-dom";
import { ScrollRestoration } from "react-router-dom";
export default function App() {
return (
<>
<ScrollRestoration />
<div className="App">
<Link to="/#hello%2520%20world">
MUST WORK AND SCROLL TO BOTTOM, BUT WORKS ONLY WITH JS DISABLED OR ON
REFRESH. CLICK ME AND REFRESH.
</Link>
<div style={{ height: "3000px" }}></div>
<Link id={"hello%20 world"}>Link</Link>
</div>
</>
);
}With disabled js first links work, and scrolls to bottom. With refresh too.
With enabled js not.
The issue is here
react-router/packages/react-router-dom/index.tsx
Line 1300 in bc25528
| let el = document.getElementById(location.hash.slice(1)); |
Must be
decodeURIComponent(location.hash.slice(1))
Expected Behavior
Should work even with js enabled
Actual Behavior
Work only if js disabled.
TrySound and FanManutd