From 3a0c53012a9db65b6f987f6d250ee0cd5674d010 Mon Sep 17 00:00:00 2001 From: Sam Tay Date: Mon, 23 Sep 2024 10:58:51 -0400 Subject: [PATCH] Fix frozen SSG --- app/src/ui/pages/birds.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/ui/pages/birds.rs b/app/src/ui/pages/birds.rs index 10a61f0..a817672 100644 --- a/app/src/ui/pages/birds.rs +++ b/app/src/ui/pages/birds.rs @@ -54,9 +54,17 @@ impl AviaryCtx { #[component] pub fn Birds() -> Element { let ctx = AviaryCtx::init(); - let no_birds = ctx.bird_ids.read().is_empty(); - if no_birds { + // NOTE: SSG hydration is finicky. This hack allows page load not to freeze. + let mut no_birds = use_signal(|| false); + if generation() == 0 { + needs_update(); + } + if generation() == 1 { + no_birds.set(ctx.bird_ids.read().is_empty()); + } + + if no_birds() { rsx! { EmptyNest {} } } else { rsx! {