-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v6: missing support for Router.basename #7128
Comments
Only possible way how to mitigate this is do introduce a "mediator" route via Embedded route // url where new router is created: https://my-site/who/users
const RootModule = () => {
return (
<BrowserRouter>
<Routes>
<Route
{/* basename alternative ✅*/}
path="who/users/*"
element={<MigratedRouteModule />}
/>
</Routes>
</BrowserRouter>
);
};
const MigratedRouteModule = () => {
return (
<section>
<nav>
<Link to="">Home</Link>
<Link to="about">About</Link>
<Link to="users">Users</Link>
</nav>
<Routes>
<Route path="/" element={<Home />} />
<Route path="about" element={<About />} />
<Route path="users" element={<Users />} />
</Routes>
</section>
);
}; |
ha! lack of docs ( i know alpha ) - use source code Martin! Solution: // url where new router is created: https://my-site/who/users
const RootModule = () => {
return (
<main>
<BrowserRouter>
<Routes basename="who/users">
<nav>
<Link to="">Home</Link>
<Link to="who/users/about">About</Link>
<Link to="who/users/users">Users</Link>
</nav>
<Routes>
<Route path="/" element={<Home />} />
<Route path="who/users/about" element={<About />} />
<Route path="who/users/users" element={<Users />} />
</Routes>
</Routes>
</BrowserRouter>
</main>
);
}; I can submit PR that updates migration guide if you want @mjackson lemme know! cheers |
Go right ahead and submit a PR. I don't think anyone is going to say no :) |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Version
6
Expected Behavior
Router supports
basename
Actual Behavior
v6
Router
is missingbasename
which makes it hard to use within various scenarios:interaction
my-site/who/users
to/about
🚨🚨🚨So what needs to be done at the moment -> to provide full path to every link/route (no relative routing possible) 🚫
interaction
my-site/who/users
tomy-site/who/users/about
✅The text was updated successfully, but these errors were encountered: