zth/rescript-relay

Experimental router polyvariant path params do not match

mattbeedle opened this issue · 5 comments

Not sure if this is already a known issue since the experimental router is still not public, but I'm having problems with the polyvariant matching.

The following code generates the correct variants, but does not match any of the /recipes/... variant paths. It will always render the Recipe renderer.

{
  "path": "recipes",
  "name": "FilteredRecipes",
  "children": [
    {
      "path": ":course(all|breakfast|lunch|dinner|appetizer|sides|dip|smoothie)",
      "name": "ByCourse"
    },
},
{
  "path": "recipes/:id",
  "name": "Recipe"
},

However, if I define every route individually it will match fine:

{
  "path": "recipes",
  "name": "FilteredRecipes",
  "children": [
    {
      "path": "all",
      "name": "All"
    },
    {
      "path": "breakfast",
      "name": "Breakfast"
     }
  }
  .......
},
{
  "path": "recipes/:id",
  "name": "Recipe"
},

I have another layer of nesting inside the each of the recipes routes and that layer is also dynamic, so manually defining every one will be quite a lot of typing :)

zth commented

Interesting! This should definitely work, thanks for reporting.

Are you actively using the router, or just trying things out?

I just refactored a current production project to use it. This is the last thing I need to get working in order to release.

zth commented

@mattbeedle let's get it sorted then! 😃 I'll invite you to the repo too since it's not public yet

Awesome, thx! I created an issue for it there along with a small sample app.

zth commented

This has been fixed in the router.