-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Refactor renderRoutes
to use matchRoutes
#6577
Conversation
This change refactors the implementation of `renderRoutes` to use `matchRoutes` instead of `Switch`, similar to the ideas mentioned in remix-run#5939.
I don't think this solves #5429. Later paths are still not being checked because For #5429, I have a problem with different layouts on multiple routes, so my route config looks something like this:
If you go to I think we need something like this in order for this to work:
Now, it will check the first route, if it's a match (and it is because it's The code is not perfect, we have a problem with duplicate routes added to the branches, but that's easy to solve. Also, the problem is that we don't know which route is more specific and I solved it by checking Something like:
I could add this logic, but I would like to get some feedback on this, I'm not sure I'm going in the right direction. Thanks! |
@burnmaniac #6575 should solve the issue of of different layouts on multiple routes, by only matching the first exact route. If it is merged, this option can be easily carried over to |
Yes, thank you for explanation. Got kinda confused with all these pull requests. 😄 If this one is merged and #6575 is merged, then we need another one to add this option to Are there any drawbacks of this? We're not going to break something else in the router because of this? It will still work for use-cases we have right now? |
If #6575 is not merged before this pull request, then we need to make another pull request to include this functionality. Otherwise, I will update it with the pull request to include it. With regard to breaking changes, the behavior of |
Okay, ping me if I can help somehow. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi again,
In relation to #6575 and as suggested in #5939, I would like to update
renderRoutes
to usematchRoutes
instead of theSwitch
component.This pull request contains an implementation of such an approach and also updates
renderRoutes
to render the whole tree (instead of only the first level), which removes the need forrenderRoutes
calls in child routes.I have left the tests as it is for now, until it clear what the behavior of
renderRoutes
should be.