diff --git a/router/src/components/outlet.rs b/router/src/components/outlet.rs index 82c3e6999a..87392a3810 100644 --- a/router/src/components/outlet.rs +++ b/router/src/components/outlet.rs @@ -52,6 +52,7 @@ pub fn Outlet() -> impl IntoView { prev_disposer.flatten() } (Some(child), _) => { + drop(prev_disposer); is_showing.set(Some(child.id())); let (outlet, disposer) = build_outlet(child); set_outlet.set(Some(outlet)); diff --git a/router/src/components/routes.rs b/router/src/components/routes.rs index deee4d1526..5ce76a8e7e 100644 --- a/router/src/components/routes.rs +++ b/router/src/components/routes.rs @@ -484,11 +484,11 @@ fn root_route( if prev.is_none() || !root_equal.get() { root.as_ref().map(|route| { - let (outlet, disposer) = outlet((*route).clone()); - drop(std::mem::replace( + drop(std::mem::take( &mut *root_disposer.borrow_mut(), - Some(disposer), )); + let (outlet, disposer) = outlet((*route).clone()); + *root_disposer.borrow_mut() = Some(disposer); outlet }) } else {