Skip to content

Commit

Permalink
Fix frozen SSG
Browse files Browse the repository at this point in the history
  • Loading branch information
samtay committed Sep 23, 2024
1 parent 8b48d3a commit 3a0c530
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/src/ui/pages/birds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down

0 comments on commit 3a0c530

Please sign in to comment.