fix switching between routes with different hooks

This commit is contained in:
Evan Almloff 2023-06-19 10:54:25 -05:00
parent 33f0e30369
commit fe626c67bd
2 changed files with 10 additions and 10 deletions

View file

@ -18,6 +18,7 @@ impl Layout {
pub fn routable_match(&self, nests: &[Nest]) -> TokenStream {
let props_name = &self.props_name;
let comp_name = &self.comp;
let name_str = self.comp.segments.last().unwrap().ident.to_string();
let dynamic_segments = self
.active_nests
.iter()
@ -25,11 +26,10 @@ impl Layout {
quote! {
let comp = #props_name { #(#dynamic_segments,)* };
let cx = cx.bump().alloc(Scoped {
props: cx.bump().alloc(comp),
scope: cx,
});
#comp_name(cx)
let dynamic = cx.component(#comp_name, comp, #name_str);
render! {
dynamic
}
}
}
}

View file

@ -145,6 +145,7 @@ impl Route {
index: usize,
) -> Option<TokenStream2> {
let name = &self.route_name;
let name_str = name.to_string();
let dynamic_segments = self.dynamic_segments();
match index.cmp(&self.layouts.len()) {
@ -168,11 +169,10 @@ impl Route {
#[allow(unused)]
Self::#name { #(#dynamic_segments,)* } => {
let comp = #props_name { #(#dynamic_segments_from_route,)* };
let cx = cx.bump().alloc(Scoped {
props: cx.bump().alloc(comp),
scope: cx,
});
#comp_name(cx)
let dynamic = cx.component(#comp_name, comp, #name_str);
render! {
dynamic
}
}
})
}