How to handle dynamic route following an optional dynamic route like ($lang)/$slug.tsx
?
#5883
Unanswered
TimoWestland
asked this question in
Q&A
Replies: 3 comments 3 replies
-
What version of Remix are you using? |
Beta Was this translation helpful? Give feedback.
0 replies
-
@sergiodxa Thanks for your reply. I'm using v1.12.0 of remix. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@sergiodxa Can we expect any changes to address this issue from the Remix team, or should we design around this limitation? |
Beta Was this translation helpful? Give feedback.
3 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.
-
In my app I have the following routing structure:
Now when you request
/en/some-slug
this works fine as$lang
will been
and$slug
will besome-slug
.However since language is optional, when you request
/some-slug
my loader in$slug.tsx
fails to make the right API call usingparams.slug
which is now undefined and passed as{ lang: 'some-slug' }
. This kind of makes sense but also feels very strange. I could make it work to useparams.lang
to make the api call whenparams.slug
is undefined, but that doesn't look very logical.According to the routing naming conventions docs this should be supported behaviour, so it seems to me I'm missing something here.
My example is the same as the 4th row in the screenshot above. In this case
american-flag-speedo
will be passed to the loader ofindex.tsx
asparams.lang
whereparams.pid
would be expected. Also it will only work ifindex.tsx
re-exports the loader and screen from$pid.tsx
asindex.tsx
will be called.Is this a bug in remix or am I just doing something completely wrong? :)
Beta Was this translation helpful? Give feedback.
All reactions