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
leptos_router parent Route attr view is not generating view for dynamic routes #2586
Comments
I'm not entirely sure what your example is supposed to show or how it relates to the problem in the application. In particular, it seems like your discussion of With very complex or dynamic routing setups like the one you're trying to create, I would suggest ditching the Alternately, if you provide a minimal reproduction (not your entire application) that illustrates the issue and try to explain more of the expected vs actual behavior I can try to help figure it out. |
Yes, as you correctly noticed, I was using Differently from what I thought, the problem doesn't come from having components between nested Since both approaches mentioned above yield the infamous Please feel free take a look on this minimal reproduction repository, as I believe it illustrates the issue better. So, as you can infer, the expected behavior is to have all 4 components routes listed and accessible in the application when iterating (or casting into I've seen your suggestion of implementing the RouteDefinition manually, but for me, it didn't look so simple to do, specially when it comes on having a concise Finally, thanks for your effort on developing Leptos, it's a great framework, indeed. |
The fundamental issue here is that This just has to do with the way the #[component(transparent)]
fn CollectedNestedRoutes() -> impl IntoView {
let nested = Route(
RouteProps::builder()
.path("/")
.view(SimpleNavComponent)
// this is very similar to the way the view macro constructs children,
// but allows you to construct the vec however you'd like rather than just adding each child
.children(ToChildren::to_children(|| {
Fragment::lazy(|| {
vec![1, 2]
.into_iter()
.map(|n: i8| view! { <DeepNestedRouteSelector url=n /> })
.collect()
})
}))
.build(),
);
view! {
<Route path="/" view=|| view! {<Html lang="en-US" /><Outlet />}>
{nested}
<Route path="/comp3" view=SimpleComponent3 />
<Route path="/comp4" view=SimpleComponent4 />
</Route>
}
} In case it's helpful in reducing boilerplate, by the way, any component with no props is just a function with no arguments -- so you can replace every instance of something like |
Greg, it really did the trick, thanks a lot. |
Describe the bug
When trying to render a
transparent
component, the parentRouter
view doesn't get rendered if I try to it dynamically. As a matter of fact, not even when trying to use static content it gets rendered.so, when I proceed to
log!("TEST TRANSPARENT {:?}", view! {<TestTransparent />}.render_to_string());
, I get an empty string, as if not even the parent component Route view has been rendered.I believe that's a bug, since at least the view on the parent
Route
should be rendered, regardless of child routes.Leptos Dependencies
To Reproduce
Steps to reproduce the behavior:
cargo leptos watch
in order for the code to build and compile;client/src/pages/locale_routes/mod.rs
in order to see where the logs come fromExpected behavior
render_to_string
should display nested components in transparent routes, regardless of dynamic or staticAdditional context
My application intends to make heavy use of
i18n
features for displaying appropriate ssr results and custom route names, to the point it makes no sense to write each one manually.Thanks for your awesome work!
The text was updated successfully, but these errors were encountered: