Skip to content
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

Support for nested routes #89

Open
taybenlor opened this issue Jun 7, 2021 · 4 comments
Open

Support for nested routes #89

taybenlor opened this issue Jun 7, 2021 · 4 comments

Comments

@taybenlor
Copy link

Hi!

This router looks great for render-as-you-fetch. But I noticed it doesn't appear to support nested routes?

This relay demo renders nested routing by rendering child routes as children. May be a possible implementation path.

@theKashey
Copy link
Collaborator

There are few reasons to keep this router "flat", predictability(or discoverability) is one of them.

Recently we implemented nested routes for "flat" router using pregeneration for routing table:

  • every layout can have a named slot for one (or more) injected children
  • so these props are just added into routing table, and then passed to the Layout component
    • recursively

Technically speaking there is no difference between this and navigation example - every route record can hold as much information as needed, including all component to be rendered as "nested routes" and all their props as well.

@taybenlor
Copy link
Author

Thanks! I think the issue I have with flat routing conceptually is that routing is a very "hierarchical" concept, and flat routing hides that hierarchy. I could potentially (as I think you've suggested) write my routes hierarchically and then use a function to flatten them out. It's not a great solution but I can understand if you feel that flat routing is a core idea of this router.

@theKashey
Copy link
Collaborator

theKashey commented Jun 10, 2021

It's more about two different metal models forming the base requirements. Let's imagine you want to defer transition to a new page until "some" stuff is loaded (like in old non-SPA sites or NextJS):

  • (relay and nested routes). useTranstion + Suspense, call it a day
  • (flat router) get information about route target, preload everything required, then perform the transition.

The outcome is (almost) the same, but realizations are different. And it order to support this, and many other patterns, without not yet production-ready Concurrent Mode you might need flat routing.

And here we are. Well, will be

@taybenlor
Copy link
Author

That makes sense! Thanks for taking the time to explain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants