Optional params? #146
Replies: 3 comments 4 replies
-
Just use the same options for both the root route and param route.
Tanner Linsley
…On Dec 9, 2021, 2:55 PM -0800, Martin Hernández Alvarado ***@***.***>, wrote:
In react router v6 they are no longer supported.
for example clients/:id? would match both /clients or /clients/1
Is there a way to achieve something like this in react location?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
Beta Was this translation helpful? Give feedback.
-
@tannerlinsley or I would have to declare 2 two routes, one with the param and one without it? const route1 = new Route({
path: 'user',
...
})
const route1 = new Route({
path: 'user/$userID',
...
}) |
Beta Was this translation helpful? Give feedback.
-
@tannerlinsley Is there a plan to make this more ergonomic? Something similar to react-router https://reactrouter.com/en/main/route/route#optional-segments? It's really annoying at the moment to support that exact pattern from the react-router link above, that is to have a lang param that sits at the root of your routes.
You can declare two different routes, one for An alternative is to redirect on "/" to "/en" (if you're doing i18n), similarly to tanstack.com:
That would work really nice for the docs as well
|
Beta Was this translation helpful? Give feedback.
-
In react router v6 they are no longer supported.
for example
clients/:id?
would match both/clients
and/clients/1
Is there a way to achieve something like this in react location?
Beta Was this translation helpful? Give feedback.
All reactions