fix: drop lock on current URL before rendering, in case of redirect (closes #2990) (#2992)

This commit is contained in:
Greg Johnston 2024-09-18 21:27:18 -04:00 committed by GitHub
parent fd133dd79a
commit c4b1176a6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 2 deletions

View file

@ -120,6 +120,9 @@ where
);
let params_memo = ArcMemo::from(params.clone());
// release URL lock
drop(current_url);
match new_match {
None => Rc::new(RefCell::new(FlatRoutesViewState {
view: EitherOf3::B(fallback()).build(),
@ -381,6 +384,10 @@ where
.unwrap_or_default(),
);
let params_memo = ArcMemo::from(params.clone());
// release URL lock
drop(current_url);
let view = match new_match {
None => Either::Left((self.fallback)()),
Some(new_match) => {
@ -543,6 +550,9 @@ where
);
let params_memo = ArcMemo::from(params.clone());
// release URL lock
drop(current_url);
match new_match {
None => Rc::new(RefCell::new(FlatRoutesViewState {
view: EitherOf3::B(fallback())

View file

@ -93,6 +93,7 @@ where
let mut loaders = Vec::new();
let mut outlets = Vec::new();
let url = current_url.read_untracked();
let path = url.path().to_string();
// match the route
let new_match = routes.match_route(url.path());
@ -110,6 +111,7 @@ where
&mut outlets,
&outer_owner,
);
drop(url);
outer_owner.with(|| {
EitherOf3::C(
Outlet(OutletProps::builder().build()).into_any(),
@ -131,7 +133,7 @@ where
});
NestedRouteViewState {
path: url.path().to_string(),
path,
current_url,
outlets,
view,
@ -411,6 +413,7 @@ where
let mut loaders = Vec::new();
let mut outlets = Vec::new();
let url = current_url.read_untracked();
let path = url.path().to_string();
// match the route
let new_match = routes.match_route(url.path());
@ -427,6 +430,8 @@ where
&mut outlets,
&outer_owner,
);
drop(url);
// TODO support for lazy hydration
join_all(mem::take(&mut loaders))
.now_or_never()
@ -442,7 +447,7 @@ where
));
NestedRouteViewState {
path: url.path().to_string(),
path,
current_url,
outlets,
view,