How to use React Router v6 nested Route
s with absolute urls?
#10288
Replies: 4 comments 5 replies
-
I suspect that this is due to you having multiple
Remix will only ever has one of these, and configures its routes like this:
This makes me think you should probably do something similar by placing a single
|
Beta Was this translation helpful? Give feedback.
-
I have the same problem, but @cairin proposal didn't solve it. Have you found the best way to migrate routes written this way to React Router V6? |
Beta Was this translation helpful? Give feedback.
-
@gustaff-weldon @daniellykammers-tr Did you find any solution for this? Or maybe a workaround? |
Beta Was this translation helpful? Give feedback.
-
I have the nice solution to allow nested absolute URL with minimal code changes. @mihaibogdan fyi |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We are migrating are big app from v5 to v6.
In our current setup, we have split our app into submodules and each module contains a special
routes
file that provides full urls to all pages within a module. The paths and urls are always absolute eg.// accounts/routes
We have plenty of such modules and respective route files. We use them both in
<Link
by generating url to a page from any place in the system by callinggetUrl
eg.routes.accounts.accountsDetails.getUrl(123)
and inRoute
by providing thepath
eg.routes.accounts.accountsDetails.path
This worked great with any level of nesting in v5, and we have several levels of components which include
<Switch>
withRoute
that can easily use that path.Now, when migrating to
Routes
andRoute
we have found that providing absolute paths to nestedRoute
make them inaccessible, ie. they do not render.Lets take the following scenario:
// Home
// Settings
// Accounts
We cannot make this to work with v6. It seems we would need to convert all the absolute urls in
Route
to paths relative to the closest parent.Are absolute urls not supported in nested
Route
in v6?Beta Was this translation helpful? Give feedback.
All reactions