React Router v7 Framework mode, server side, optional route parameters #14124
Unanswered
michelbieleveld
asked this question in
Q&A
Replies: 0 comments
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.
-
Hi, how would I detect whether a route has an optional parameter that is null vs not being defined. In other words, how can I detect if the route has an optional lang parameter ( file based routing):
($lang).dashboard.tsx
someother.tsx
I would expect:
/dashboard.tsx -> lang = null
/en/dashboard.tsx -> lang = en
/someother.tsx -> lang = undefined
It seems that the lang = null does not happen, it is just missing on params and hence undefined. (Or likely I am doing something wrong) I am trying to do this test in middleware.
The goal would be to redirect to a default language in case there is a language dependent version of that route. Open to other suggestions to solve this problem too.
Beta Was this translation helpful? Give feedback.
All reactions