#Routable -> Nested layout with parameters "cannot find value ... in scope"

1 messages · Page 1 of 1 (latest)

lament reef
#

The following code is my route:

#[derive(Debug, Clone, Routable, PartialEq)]
#[rustfmt::skip]
enum Route {
    #[route("/")]
    Home {},
    #[route("/projects")]
    ProjectOverview {},
    #[nest("/projects/:project_id")]
        #[layout(Project)]
            #[route("/")]
            ProjectWithoutBlock { project_id: String },
            #[route("/:block_id")]
            ProjectWithBlock { project_id: String, block_id: String },
    #[end_nest]
    //  if the current location doesn't match any of the above routes, render the NotFound component
    #[route("/:..segments")]
    NotFound { segments: Vec<String> },
}

As soon as I add my layout "Project", I get the error in the title ("cannot find value project_id in scope":

#[component]
pub fn Project(project_id: String) -> Element {
    rsx! {
            Outlet::<crate::Route> {}
        }
    }
}

What could be the issue? Again, this works fine without layout.

kind locust
#

I think you need a #[end_layout] before the #[end_nest]

lament reef
#

That JUST WORKED 🥳