Skip to content

Router Switch is order dependant #1679

@theduke

Description

@theduke

Problem

With the below router definition, the router will always match the Home route and ignore the other definitions.

Maybe "/" has some special match-all semantics?

Making Home the last variant will make things work properly.

This is highly confusing behaviour, I spent quite a bit of time tracking this down.

#[derive(yew_router::Switch, Debug, Clone)]
pub enum AppRoute {
   #[to = "/"]
    Home,
    #[to = "/feed/{category}"]
    Feed(String),
    #[to = "/post/{id}"]
    Post(u64),
}

Environment:

  • Yew version: 0.17.4
  • yew-router: 0.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions