Merge pull request #239 from gbj/router-off-by-one

Fixes off-by-one error in the router that was causing inappropriate scope disposal
This commit is contained in:
Greg Johnston 2023-01-05 09:47:39 -05:00 committed by GitHub
commit ed023c8970
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -20,7 +20,6 @@ pub fn Outlet(cx: Scope) -> impl IntoView {
}
(Some(child), prev) => {
if let Some(prev_scope) = prev.map(|(_, scope)| scope) {
leptos::log!("disposing previous scope");
prev_scope.dispose();
}
is_showing.set(Some((child.id(), child.cx())));

View file

@ -140,7 +140,8 @@ pub fn Routes(
if disposers.borrow().len() > i + 1 {
let mut disposers = disposers.borrow_mut();
let old_route_disposer = std::mem::replace(&mut disposers[i], disposer);
let old_route_disposer =
std::mem::replace(&mut disposers[i + 1], disposer);
old_route_disposer.dispose();
} else {
disposers.borrow_mut().push(disposer);