Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Demo switch version #155

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions demo/src/components/switch_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ pub fn SwitchVersion() -> impl IntoView {
cfg_if::cfg_if! {
if #[cfg(any(feature = "csr", feature = "hydrate"))] {
let location = window().location();
let host = location.host().ok();
let version = RwSignal::new(host);
let _ = version.watch(move |host| {
if let Some(host) = host {
let origin = location.origin().ok();
let version = RwSignal::new(origin);
let _ = version.watch(move |origin| {
if let Some(origin) = origin {
let pathname = location.pathname().unwrap_or_default();
let href = format!("{}{}", host, pathname);
let href = format!("{}{}", origin, pathname);
let _ = location.set_href(&href);
}
});
Expand Down
Loading