Skip to content

Commit

Permalink
fix: correct ownership in redirect route hook (closes #3425)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj committed Dec 31, 2024
1 parent 7a5b27a commit 146c36c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion router/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,18 @@ where

#[cfg(not(feature = "ssr"))]
let (location_provider, current_url, redirect_hook) = {
let owner = Owner::current();
let location =
BrowserUrl::new().expect("could not access browser navigation"); // TODO options here
location.init(base.clone());
provide_context(location.clone());
let current_url = location.as_url().clone();

let redirect_hook = Box::new(|loc: &str| BrowserUrl::redirect(loc));
let redirect_hook = Box::new(move |loc: &str| {
if let Some(owner) = &owner {
owner.with(|| BrowserUrl::redirect(loc));
}
});

(Some(location), current_url, redirect_hook)
};
Expand Down

0 comments on commit 146c36c

Please sign in to comment.