After upgrading to React Router v6, my application stopped working and I failed to find a way to achieve the same behavior with version 6.
This is the version I upgraded to: react-router-dom 6.2.1.
This is the code that worked with the previous version 5.2.0:
<Router basename="/#">
<Route path="/login">
<Login />
</Route>
<Route path="/">
<Home />
</Route>
</Router>
<Link to="/login">Login</Link>
And I navigate to http://localhost:3000/#/login. Now even http://localhost:3000 doesn't work.
This is the full error I get in the browser console:
<Router basename="/#"> is not able to match the URL "/" because it does not start with the basename, so the <Router> won't render anything.
I've read all I can find on StackOverflow, in the Github issues, the migration guide, tried a number of workarounds, but nothing seems to achieve the old behavior. It's like the v6 doesn't respect URL fragments at all.
I need the URL fragments so that when a user refreshes a page or bookmarks a URL, it actually works.
How to make this work with React Router v6?