DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
19.33k stars 736 forks source link

Fix hydration for static text nodes at the root of the template #2184

Closed ealmloff closed 3 months ago

ealmloff commented 3 months ago

This PR fixes hydration for static text nodes at the root of templates. Here is a small example that works on this branch, but is broken in the published version of dioxus:

use dioxus::prelude::*;

fn main() {
    launch(app);
}

fn app() -> Element {
    let mut count = use_signal(|| 0);

    rsx! {
        h1 { "High-Five counter: {count}" }
        button { onclick: move |_| count += 1, "Up high!" }
        button { onclick: move |_| count -= 1, "Down low!" }
        if count() > 10 {
            "Big number!"
        }
        else {
            "Small number!"
        }
    }
}

Fixes https://github.com/DioxusLabs/docsite/issues/234