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

Inline rsx within match never reevaluated when on of the arm's returns an empty rsx. #2020

Closed
lostb1t opened this issue Mar 8, 2024 · 2 comments · Fixed by #2026
Closed
Assignees
Labels
bug Something isn't working rsx Related to rsx or the dioxus-rsx crate

Comments

@lostb1t
Copy link

lostb1t commented Mar 8, 2024

Inline rsx within match never reevaluated when on of the arm's renders an empty rsx.

In the example hello world is never re-rendered after toggling.

use dioxus::prelude::*;

fn main() {
    launch(app);
}

fn app() -> Element {
    let mut running = use_signal(|| true);

    rsx! {
        div {
            button { onclick: move |_| running.toggle(), "Toggle" }
            match running() {
                true => {
                    rsx! {
                        "Hello world"
                    }
                }
                // works
                // false => rsx!{div {}}
                // does not work, hello world never rerenders.
                false => rsx!{}
            }
        }
    }
}
@ealmloff ealmloff added bug Something isn't working rsx Related to rsx or the dioxus-rsx crate labels Mar 8, 2024
@ealmloff
Copy link
Member

ealmloff commented Mar 8, 2024

rsx!{} expands to a template with no nodes. Because it has no root nodes, dioxus doesn't know what to replace with "Hello world". Instead of rendering no nodes, we should treat rsx!{} like rsx!{{}} which renders a placeholder

@jkelleyrtp
Copy link
Member

Fixed by #2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rsx Related to rsx or the dioxus-rsx crate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants