provide params properly in FlatRouter
This commit is contained in:
parent
53b22a9b74
commit
420dccda60
|
@ -1,6 +0,0 @@
|
|||
[unstable]
|
||||
build-std = ["std", "panic_abort", "core", "alloc"]
|
||||
build-std-features = ["panic_immediate_abort"]
|
||||
|
||||
[build]
|
||||
target = "aarch64-apple-darwin"
|
|
@ -10,7 +10,7 @@ crate-type = ["cdylib", "rlib"]
|
|||
console_error_panic_hook = "0.1"
|
||||
console_log = "1"
|
||||
lazy_static = "1"
|
||||
leptos = { path = "../../leptos", features = ["nightly", "hydration"] }
|
||||
leptos = { path = "../../leptos", features = ["hydration" ] } #"nightly", "hydration"] }
|
||||
leptos_meta = { path = "../../meta" }
|
||||
leptos_axum = { path = "../../integrations/axum", optional = true }
|
||||
leptos_router = { path = "../../router" }
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
[toolchain]
|
||||
channel = "stable" # test change
|
|
@ -5,6 +5,7 @@ use crate::{
|
|||
State, Url,
|
||||
},
|
||||
navigate::{NavigateOptions, UseNavigate},
|
||||
params::ParamsMap,
|
||||
resolve_path::resolve_path,
|
||||
FlatRoutesView, MatchNestedRoutes, NestedRoute, NestedRoutesView, Routes,
|
||||
SsrMode,
|
||||
|
@ -267,11 +268,13 @@ where
|
|||
});
|
||||
let outer_owner =
|
||||
Owner::current().expect("creating Router, but no Owner was found");
|
||||
let params = ArcRwSignal::new(ParamsMap::new());
|
||||
move || FlatRoutesView {
|
||||
routes: routes.clone(),
|
||||
path: path.clone(),
|
||||
fallback: fallback(),
|
||||
outer_owner: outer_owner.clone(),
|
||||
params: params.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ pub(crate) struct FlatRoutesView<Defs, Fal, R> {
|
|||
pub path: ArcMemo<String>,
|
||||
pub fallback: Fal,
|
||||
pub outer_owner: Owner,
|
||||
pub params: ArcRwSignal<ParamsMap>,
|
||||
}
|
||||
|
||||
impl<Defs, Fal, R> FlatRoutesView<Defs, Fal, R>
|
||||
|
@ -57,14 +58,18 @@ where
|
|||
path,
|
||||
fallback,
|
||||
outer_owner,
|
||||
params,
|
||||
} = self;
|
||||
|
||||
outer_owner.with(|| {
|
||||
provide_context(params.clone().read_only());
|
||||
let new_match = routes.match_route(&path.read());
|
||||
match new_match {
|
||||
None => Either::Left(fallback),
|
||||
Some(matched) => {
|
||||
let params = matched.to_params();
|
||||
let new_params =
|
||||
matched.to_params().into_iter().collect::<ParamsMap>();
|
||||
params.set(new_params);
|
||||
let (view, child) = matched.into_view_and_child();
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
|
|
Loading…
Reference in New Issue