fix layouts in child routes

This commit is contained in:
Evan Almloff committed 2023-07-13 19:56:30 -07:00
1 parent 128f3e4425
commit 5f37dcc2ac
2 files changed
+12 -2

No files matched your search

+10
View File
@@ -119,6 +119,8 @@ pub fn GenericRouter<R: Routable + Clone>(cx: Scope<GenericRouterProps<R>>) -> E
where
<R as FromStr>::Err: std::fmt::Display,
{
use crate::prelude::outlet::OutletContext;
use_context_provider(cx, || {
GenericRouterContext::new(
(cx.props
@@ -129,6 +131,10 @@ where
cx.schedule_update_any(),
)
});
use_context_provider(cx, || OutletContext::<R> {
current_level: 0,
_marker: std::marker::PhantomData,
});
render! {
GenericOutlet::<R> {}
@@ -152,6 +158,10 @@ where
cx.schedule_update_any(),
)
});
use_context_provider(cx, || OutletContext::<R> {
current_level: 0,
_marker: std::marker::PhantomData,
});
render! {
GenericOutlet::<R> {}
+2 -2
View File
@@ -4,7 +4,7 @@ use crate::{routable::Routable, utils::use_router_internal::use_router_internal}
pub(crate) struct OutletContext<R> {
pub current_level: usize,
_marker: std::marker::PhantomData<R>,
pub _marker: std::marker::PhantomData<R>,
}
impl<R> Clone for OutletContext<R> {
@@ -19,7 +19,7 @@ impl<R> Clone for OutletContext<R> {
pub(crate) fn use_outlet_context<R: 'static>(cx: &ScopeState) -> &OutletContext<R> {
let outlet_context = cx.use_hook(|| {
cx.consume_context().unwrap_or(OutletContext::<R> {
current_level: 0,
current_level: 1,
_marker: std::marker::PhantomData,
})
});