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

Dioxus Router spread routes don't parse #1293

Closed
3 tasks
YourNighty opened this issue Aug 4, 2023 · 0 comments · Fixed by #1298
Closed
3 tasks

Dioxus Router spread routes don't parse #1293

YourNighty opened this issue Aug 4, 2023 · 0 comments · Fixed by #1298
Labels
bug Something isn't working router Related to the router implementation

Comments

@YourNighty
Copy link

In the example documentation at https://dioxuslabs.com/learn/0.4/router/example/first-route the PageNotFound Component is not working as I expected. I am not receiving any routes in the string vector (length of vec == 0). Url is changing fine.

No other behaviour when I used a Link explicitly to the PageNotFound Route with example routes in the vec. 🙂

Steps To Reproduce

Steps to reproduce the behavior:

#![allow(non_snake_case)]

use dioxus::prelude::*;
use dioxus_router::prelude::*;

fn main() {
    dioxus_web::launch(App);
}

#[derive(Routable, Clone)]
enum Route {
    #[route("/")]
    Home {},
    #[route("/blog/:number")]
    Blog { number: usize },
    // PageNotFound is a catch all route that will match any route and placing the matched segments in the route field
    #[route("/:..route")]
    PageNotFound { route: Vec<String> },
}

pub fn App(cx: Scope) -> Element {
    render! { Router::<Route> {} }
}

#[inline_props]
fn Home(cx: Scope) -> Element {
    render! {
            h1 { "Welcome Home!" }
            Link {
                to: Route::PageNotFound {
        route: vec!["Hello".to_string(), "World".to_string()],
    },
                "To PageNotFound"
            }
        }
}

#[inline_props]
fn Blog(cx: Scope, number: usize) -> Element {
    render! { h1 { "Blog: {number}" } }
}

#[inline_props]
fn PageNotFound(cx: Scope, route: Vec<String>) -> Element {
    let length = route.len();
    render! {
        h1 { "route length: {length}" }
        h1 { "Page not found" }
        p { "We are terribly sorry, but the page you requested doesn't exist." }
        pre { color: "red", "log:\nattemped to navigate to: {route:?}" }
        Link { to: Route::Home {}, "Home" }
    }
}

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment:

  • Dioxus version: [v0.4.0]
  • Dioxus-Web version: [v0.4.0]
  • Dioxus-Router version: [v.0.4.1]
  • Rust version: [v1.70.0, stable]
  • OS info: [Windows]
  • App platform: [web]

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
@ealmloff ealmloff changed the title Dioxus Router Dioxus Router spread routes don't parse Aug 4, 2023
@ealmloff ealmloff added bug Something isn't working router Related to the router implementation labels Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working router Related to the router implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants