Skip to content

Commit

Permalink
fix: dispose previous route or outlet before rendering new one (closes
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj authored Nov 24, 2023
1 parent 670f415 commit d531848
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions router/src/components/outlet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions router/src/components/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d531848

Please sign in to comment.