-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiple params, no parent #9
Comments
I also just tried to trick it with this, note all the
And got another incorrect route config:
Which brings up the question, should these two be equivalent?
I think so. The explicit
But in the absence of <Routes>
<Route file="root.tsx">
<Route path="healthcheck" file="routes/healthcheck.tsx" />
<Route path=":lang/:ref" file="routes/$lang.$ref.tsx">
<Route index file="routes/$lang.$ref/index.tsx" />
<Route path="*" file="routes/$lang.$ref/$.tsx" />
</Route>
<Route index file="routes/index.tsx" />
</Route>
</Routes> |
Thanks for the issue and examples. I'll get this fixed. |
I think the trick is figuring out where to nest your layouts. Without folders to indicate parent, we're left with defaulting to nest under the previous segment. But if your parent was a flat layout like Perhaps the trailing underscore should act like the
Turns into
It assumes the parent segment is the parent layout, but if the parent segment ends with Again, flat-routes will assume that dots are slashes until it finds a segment ending in I think putting the What do you think? |
I think I've fixed it!
<Routes>
<Route file="root.tsx">
<Route path=":lang/:ref" file="ryanroutes2/$lang.$ref/_index.tsx">
<Route path="*" file="ryanroutes2/$lang.$ref.$/_index.tsx" />
<Route index file="ryanroutes2/$lang.$ref._index/_index.tsx" />
</Route>
<Route index file="ryanroutes2/_index/_index.tsx" />
<Route path="healthcheck" file="ryanroutes2/healthcheck/_index.tsx" />
</Route>
</Routes> |
Awesome work! I love this.
I tried it on the revamp the react router docs site and had this route config:
Which creates this route tree with
$ remix routes
I ran the migration script and it kicked out:
Which creates this incorrect route tree:
$lang_.$ref
:lang/:ref
I'm realizing my examples never handled the case where a single route defines multiple segments
<Route path=":lang/:ref" />
, and it looks like the migration script andflatroutes
aren't handling it either!I changed my files to this, which I think is what the correct output of the migration script should be:
But the route config has an even bigger disappearing act with that 😶🌫️
It should look like this:
The tricky bit here is when you see
$lang.$ref
and don't find a$lang
to be the parent, we need to treat$lang.$ref
as it's own route without needing a parent.Of course, if the app developer adds a
$lang
then the route config will completely change on them, and I'd consider that expected behavior.The text was updated successfully, but these errors were encountered: