fix can go back hydration (#4209)

This commit is contained in:
Evan Almloff authored and GitHub committed 2025-06-18 16:48:59 -07:00
1 parent a0ab159c01
commit 315854b449
10 files changed
+190 -8

No files matched your search

@@ -29,6 +29,9 @@ enum Route {
#[route("/error")]
ThrowsError,
#[route("/can-go-back")]
HydrateCanGoBack,
}
#[component]
@@ -52,3 +55,39 @@ fn Home() -> Element {
"Home"
}
}
#[component]
pub fn HydrateCanGoBack() -> Element {
let navigator = use_navigator();
let mut count = use_signal(|| 0);
rsx! {
header {
class:"flex justify-start items-center app-bg-color-primary px-5 py-2 space-x-4",
if navigator.can_go_back() {
button {
class: "app-button-circle item-navbar",
onclick: move |_| {
count += 1;
},
"{count}"
},
}
else {
div {
Link {
class: "app-button-circle item-navbar",
to: Route::Home,
"Go to home"
},
button {
class: "app-button-circle item-navbar",
onclick: move |_| {
count += 1;
},
"{count}"
},
}
}
},
}
}