Skip to content

Commit

Permalink
Revisions.
Browse files Browse the repository at this point in the history
  • Loading branch information
finnbear committed Sep 19, 2024
1 parent 69b6126 commit 3acd667
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 0 additions & 4 deletions packages/yew-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ pub mod history {
AnyHistory, BrowserHistory, HashHistory, History, HistoryError, HistoryResult, Location,
MemoryHistory,
};

pub(crate) mod query {
pub(crate) use gloo::history::query::Raw;
}
}

pub mod prelude {
Expand Down
7 changes: 4 additions & 3 deletions packages/yew-router/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
use std::borrow::Cow;
use std::rc::Rc;

use gloo::history::query::Raw;
use yew::prelude::*;
use yew::virtual_dom::AttrValue;

use crate::history::query::Raw;
use crate::history::{AnyHistory, BrowserHistory, HashHistory, History, Location};
use crate::navigator::Navigator;
use crate::utils::{base_url, strip_slash_suffix};
Expand Down Expand Up @@ -77,7 +77,8 @@ fn base_router(props: &RouterProps) -> Html {
let basename = basename.map(|m| strip_slash_suffix(&m).to_string());
let navigator = Navigator::new(history.clone(), basename.clone());

let old_basename = use_state_eq(|| Option::<String>::None);
let old_basename = use_mut_ref(|| Option::<String>::None);
let mut old_basename = old_basename.borrow_mut();
if basename != *old_basename {
// If `old_basename` is `Some`, path is probably prefixed with `old_basename`.
// If `old_basename` is `None`, path may or may not be prefixed with the new `basename`,
Expand All @@ -86,7 +87,7 @@ fn base_router(props: &RouterProps) -> Html {
history.clone(),
old_basename.as_ref().or(basename.as_ref()).cloned(),
);
old_basename.set(basename.clone());
*old_basename = basename.clone();
let location = history.location();
let stripped = old_navigator.strip_basename(Cow::from(location.path()));
let prefixed = navigator.prefix_basename(&stripped);
Expand Down

0 comments on commit 3acd667

Please sign in to comment.