You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason for this is that we want layouts to (by default) be "inherited" also to Flow views. If I have views/foo/$layout.tsx, then I would want a Flow view with @Route("foo/bar") to be rendered inside that layout. This in turn means that a separate /* catch-all that delegates to the server would be needed on every level in the config that has a layout. serverRoutes doesn't know which parts of fileRoutes has layouts and with doesn't know that serverRoutes should be applied in a different way compared to fileRoutes.
There's one thing that is not clear to me based on that example: what mental model should I use to understand whether '/login' will be wrapped in side views/$layout.tsx and how should I change the code if I want to make it work in the opposite way?
There's one thing that is not clear to me based on that example: what mental model should I use to understand whether '/login' will be wrapped in side views/$layout.tsx and how should I change the code if I want to make it work in the opposite way?
Good question. I'd suggest that it is not wrapped by default, unless explicitly declared so:
I think there should be some kind low-level API that allows making arbitrary changes to the data structure that will eventually be converted into a React Router configuration. It should be possible for expert users to do those kinds of changes at any point during processing (i.e. before or after any of the default steps that are shown in the current code example). All high-level API that we introduce (e.g. withFileRoutes) would then just be shorthands on top of that generic operation. The key point is just that the generic operation also needs to be exposed and documented.
Another thought is that withServerFallback might be a weird name from a semantic point of view. The point with is just that it's a fallback that is applied in all cases when no explicitly defined route matches while still following intermediate layouts. In that way, it's a "universal" fallback but not in any way specific to "server" (except maybe some support for asynchronous resolving but that can also be seen as a universal feature).
By the way, will this new implementation of file route register an empty route always as previously? Seems like it shouldn't, so as to avoid issues like not being able to use AtRoute("") in Flow.
Activity
Legioth commentedon Mar 21, 2024
I don't think it can be this easy:
The reason for this is that we want layouts to (by default) be "inherited" also to Flow views. If I have
views/foo/$layout.tsx, then I would want a Flow view with@Route("foo/bar")to be rendered inside that layout. This in turn means that a separate/*catch-all that delegates to the server would be needed on every level in the config that has a layout.serverRoutesdoesn't know which parts offileRouteshas layouts andwithdoesn't know thatserverRoutesshould be applied in a different way compared tofileRoutes.Legioth commentedon Mar 22, 2024
There's one thing that is not clear to me based on that example: what mental model should I use to understand whether
'/login'will be wrapped in sideviews/$layout.tsxand how should I change the code if I want to make it work in the opposite way?platosha commentedon Mar 25, 2024
Good question. I'd suggest that it is not wrapped by default, unless explicitly declared so:
This way creates feels less magic to me, hopefully more flexible and easier to understand.
Legioth commentedon Mar 25, 2024
That's with an explicitly defined
<Layout />component. How about making manually defined routes render insideviews/$layout.tsx.Legioth commentedon Mar 26, 2024
I think there should be some kind low-level API that allows making arbitrary changes to the data structure that will eventually be converted into a React Router configuration. It should be possible for expert users to do those kinds of changes at any point during processing (i.e. before or after any of the default steps that are shown in the current code example). All high-level API that we introduce (e.g.
withFileRoutes) would then just be shorthands on top of that generic operation. The key point is just that the generic operation also needs to be exposed and documented.Another thought is that
withServerFallbackmight be a weird name from a semantic point of view. The point with is just that it's a fallback that is applied in all cases when no explicitly defined route matches while still following intermediate layouts. In that way, it's a "universal" fallback but not in any way specific to "server" (except maybe some support for asynchronous resolving but that can also be seen as a universal feature).mshabarov commentedon Mar 27, 2024
By the way, will this new implementation of file route register an empty route always as previously? Seems like it shouldn't, so as to avoid issues like not being able to use AtRoute("") in Flow.
feat: Use a new RouterBuilder API for routes.tsx (#19020)
vaadin-bot commentedon Apr 10, 2024
This ticket/PR has been released with Vaadin 24.4.0.alpha21 and is also targeting the upcoming stable 24.4.0 version.