Replies: 1 comment
-
Nevermind, this seems to work by passing <Routes>
<Route path="/" element={<Navigate href="/locations" />} />
<Route path="/login" component={Login} />
<Route path="/locations" component={Locations}>
<Route path="/" component={LocationsIndex} data={LocationsIndexData} />
<Route path="/:locationId" component={Location} data={LocationData}>
<Route path="/" element={<Navigate href="./home" />} />
<Route path="/home" component={Home} data={HomeData} />
<Route path="/settings" component={Settings} data={SettingsData} />
</Route>
</Route>
</Routes> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Let's say an example app has this as part of its routing structure:
In this case, if the user visits
https://example.com/
, they'll be redirected tohttps://example.com/locations
. Let's also say that a new requirement for the application is that when a user visitshttps://example.com/locations/123
, they get redirected tohttps://example.com/locations/123/home
. One might think you can add another Route + Navigate like this:However, this won't work. If you pass the new
<Navigate />
anhref
prop of/home
, you'll get redirected tohttps://example.com/home
. If you pass it anhref
prop of/locations/:locationId/home
, you'll get redirected tohttps://example.com/locations/:locationId/home
(this is not a placeholder, the colon is really in the URL). I don't believe there's anything you can pass thehref
prop that'll get you redirected fromhttps://example.com/locations/123
tohttps://example.com/locations/123/home
.In an ideal world, there'd be an easy way to tell the SolidJS Router that I'd like to navigate to a given URL within the context of existing
dynamic segmentsparameters, without needing to look up the current values and construct a new string. One could imagine how it would be even more tedious to look up & concatenate parameters in the case of a URL structure likehttps://example.com/locations/123/widgets/456/comments/789/edit
.I'd love this to be possible. In fact, it'd be nice if it was not only possible, easy, and documented for
<Navigate />
-- but also foruseNavigation()
and<A />
as well!Beta Was this translation helpful? Give feedback.
All reactions