pateketrueke/yrv

Nested routers, sub route (two slashes) broken

Closed this issue · 5 comments

REPL: https://svelte.dev/repl/452d344c72a048818a31aa1af48722af?version=3.20.1

I think we have a new issue or a new FAQ for nested routers.

I'm calling from a nested router a route with two slashes:

/ --> /players --> /team/new: NOTHING appears!

Cool! Gonna play with it.

Found the root-cause of your issue: just remove the exact prop from the top-level route for /players — the reason is that we're using such prop to cleanup previously-exact-matches after we resolve nested ones.

It works.

But now I'm really confused about exact mechanism.

😕

Say you have three routes:

  • /a (exact)
  • /a/b (non-exact)
  • /a/b/c (exact)

Now, you navigate from /a to /a/b/c:

  • Since /a was active, and it was exact, yrv clears out the routeInfo for that route.
  • Since /a/b is not exact, yrv activate this route because is half-way to the final route.

The key for choosing which routes should be exact or not? If you plan to have more routes nested, then the route will never be exact (at least at top-levels).

Makes sense. Thanks.